How to run a vbscript in wix burn ExePackage? - batch-file

I need to make some changes in an xml file after I've installed a couple of MSI. For that I was thinking calling a vbscript using the bat file with the %* trick. My problem is that I get an 0X80070001 error, but when I run the script manually it works fine.
Code in chain:
<ExePackage
Id="CultureChange"
SourceFile="run.bat"
DisplayName="Changing Default Language"
InstallCommand='cscript Script.vbs "[DefaultCulture]"'
PerMachine="yes"
Cache="yes"
Compressed="yes">
<Payload SourceFile="Script.vbs"/>
</ExePackage>
I also tried calling cscript with C:\windows\SysNative\cscript.exe but same result.
log:
Applying execute package: CultureChange, action: Install, path: C:\ProgramData\Package Cache\1608BB75347CD8C40187E5F3C0A969ED73A98D51\run.bat, arguments: '"C:\ProgramData\Package Cache\1608BB75347CD8C40187E5F3C0A969ED73A98D51\run.bat" C:\windows\SysNative\cscript.exe Script.vbs "it-IT"'
Error 0x80070001: Process returned error: 0x1
Error 0x80070001: Failed to execute EXE package.
Error 0x80070001: Failed to configure per-machine EXE package.
Also note that the MSI can't be modified so I can't make the changes in the xml file there.
Update:
I gave a solution that worked on Windows 8.1 but when I tested it on Windows 7 it still gave me the same error.
here is the code:
#echo off
pushd %~dp0
C:\Windows\SysWOW64\cmd.exe /c cscript Script.vbs "%1"
I also found some documentation on the error:
https://msdn.microsoft.com/en-us/library/windows/desktop/dd319335(v=vs.85).aspx
A write request was made to a resource on the device that was opened
in Read mode using IPortableDeviceResources::GetStream, or a read
request was made to a resource opened for Write or Create.
I watched the vbscript file and it was never accessed.
Anyway, I went with editing the xml file in my managed bootstrapper in c# and not trying to run the vbscript but I'm leaving this question open since it's not really a good enough solution.

Related

Unable to execute pre-build event stored in batch file at the time of publishing WPF application

I am executing a T4 template using a pre-build event with the following script added in the Properties > Build Events > Pre-build event command line:
set textTemplatingPath="%CommonProgramFiles(x86)%\Microsoft Shared\TextTemplating\$(VisualStudioVersion)\texttransform.exe"
if %textTemplatingPath%=="\Microsoft Shared\TextTemplating\$(VisualStudioVersion)\texttransform.exe" set textTemplatingPath="%CommonProgramFiles%\Microsoft Shared\TextTemplating\$(VisualStudioVersion)\texttransform.exe"
%textTemplatingPath% "$(ProjectDir)AssemblyFileVersion.tt"
While building the solution the above script is working fine and I am able to get output from T4 template file. But I am looking to execute this script while publishing the WPF application instead of building the solution.
I have moved the script in the batch file and put a reference of that batch file inside .csproj file.
<Target Name="BeforePublish" BeforeTargets="MSDeployPublish">
<Exec Command="$(SolutionDir)v1.bat" />
</Target>
While I am publishing the project, I am getting following error.
The command "xx\v1.bat" exited with code 9009
The file exists in the location but I am not able to figure out if there is an issue with the script or the way I am trying to achieve the result.
Edit:
When I checked the Output window, it was due to the space in one of the directories (Visual Studio 2015 in my case) included in the path. For now, I have placed v1.bat inside D: folder.
<Target Name="BeforePublish" BeforeTargets="MSDeployPublish">
<Exec Command="D\v1.bat" />
</Target>
Now when I am trying to publish the app, it shows me the following error.
The command "D:\v1.bat" exited with code 1
and the Output window is showing "The system cannot find the path specified".
It seems like the problem is with the variables used in the script and not in the path of the v1.bat file defined in the Target above because when I am simply keeping echo StackOverflow in the batch file it is showing the text and successfully publishing the app. To me, it seems like the way I used the script in the pre-build command line in Visual Studio IDE would be quite different the way if I need to run the same script from batch file.
Thanks
The following pre-build event script added in the Properties > Build Events > Pre-build event command line in Visual Studio IDE:
set textTemplatingPath="%CommonProgramFiles(x86)%\Microsoft Shared\TextTemplating\$(VisualStudioVersion)\texttransform.exe"
if %textTemplatingPath%=="\Microsoft Shared\TextTemplating\$(VisualStudioVersion)\texttransform.exe" set textTemplatingPath="%CommonProgramFiles%\Microsoft Shared\TextTemplating\$(VisualStudioVersion)\texttransform.exe"
%textTemplatingPath% "$(ProjectDir)AssemblyFileVersion.tt"
needs some changes when it is moved to a batch file which is intended to be executed while publishing the application instead of building it.
I need to change all variables from $(Variable1) to %Variable1%, so my script became
set textTemplatingPath="%CommonProgramFiles(x86)%\Microsoft Shared\TextTemplating\%VisualStudioVersion%\texttransform.exe"
if %textTemplatingPath%=="\Microsoft Shared\TextTemplating\%VisualStudioVersion%\texttransform.exe" set textTemplatingPath="%CommonProgramFiles%\Microsoft Shared\TextTemplating\%VisualStudioVersion%\texttransform.exe"
%textTemplatingPath% "%ProjectDir%AssemblyFileVersion.tt"

Execute a Workflow KNIME with a Batch file

I would like to execute a workflow KNIME with a Batch file but i have an error :
ERROR KNIME-Worker-2 Call Local Workflow Execute failed : java.lang.NullPointerException
My workflow knime work well on Knime but i don't know why I have this error.
This is my Batch file :
"C:\Program Files\KNIME\knime.exe" -nosave -consoleLog -noexit -nosplash -reset
-application org.knime.product.KNIME_BATCH_APPLICATION
-preferences="C:\Users\Admnistrator\Desktop\KNIME_Preferences.epf"
-workflowDir="C:\Users\Admnistrator\knime-workspace\SPC_SIMTest"
Knime report Java :
Java was started but returned exit code = 4
I'm not find solution. Can you help me ?
If you run the command without options, e.g. eclipsec.exe -consoleLog -noexit -nosplash -launcher.suppressErrors -application org.knime.product.KNIME_BATCH_APPLICATION
then you will see a list of the available options and the java return codes. In particular, return code 4 indicates if an error during execution occurred
Often this sort of problem can be fixed by openning the workflow in the KNIME desktop, checking for any errors, reset the workflow and save it again, as an error during loading (e.g partially executed loops to pick a common one) could cause problems. Then try re-loading the workflow in the KNIME desktop and check no errors during load are recorded during the console. Also, adding the option --launcher.suppressErrors to your command line can sometimes avoid issues like this.

Post-Build Event Fails to Run Batch File

I recently started adding Post-Build events to my projects and today I came across an annoying issue.
Post-build event command line:
"$(ProjectDir)PostBuildRelease.bat"
PostBuildRelease.bat - 1
CMD
SET parameter=%1
CD %1
The above errors with message:
'´╗┐CMD' is not recognized as an internal or external command,
operable program or batch file.
"Saved parameter "
Which is strange, because I definitely have another project where the first line reads CMD and it works perfectly.
Setting the first line to SET parameter=%1 also complains that SET is not a recognised command.
PostBuildRelease.bat - 2
Trying the same but with an empty file gives this error (build fails):
The command "C:\Users\name\ITSelfHelp\ITHelp\PostBuildRelease.bat" exited with code 1.
PostBuildRelease - 3
Entering the CMD code directly into the Post-Build Event command line field results in a successful post-build event, but this is not ideal for me and seems strange as I can run from an external .bat in other projects.
Can anyone explain this behaviour, or let me know how I can debug this?
It turns out the text editor in Visual Studio was encoding my batch script.
To recreate this:
Right-click the solution
Add file
Text file
Rename file.bat
Write the script in Visual Studio
Build
Check the output window for the error
To resolve:
Delete the file created in Visual Studio
Created a new .bat file in the same location using Windows Explorer
Open the file with Notepad++ and paste in the script
Save and build
I also noticed that syntax highlighting was not being applying in the file created by Visual Studio, which is a bit of a giveaway along with the ´╗┐ in front of the errors.

Failed to open package file due to error 0x800070035

Full error message:
Could not load package "\\File.dtsx" because of error 0xC0011002.
Description: Failed to open package file "\\File" due to error 0x80070035 "The network path was not found.". This occurs when loading a package and the file cannot be opened or loaded correctly into the XML document. This can be the result of specifying an incorrect file name when calling LoadPackage or the specified XML file has an incorrect format.
This is a really strange issue. We have an SSIS package which is called via dtexec in a batch file. The SSIS package runs in 64 bit and we also use the 64 bit version of dtexec.
We have a task scheduler which calls the batch file which calls package. It looks like so:
cd C:\Program Files\Microsoft SQL Server\120\DTS\Binn
dtexec.exe /f "\\local\it$\Development\.NET Projects\Reporting\DailyUpload_DEV\DailyUpload\File.dtsx"
However sometimes the package will run with no problems at all and sometimes it throws an error which you can see above.
Why is this happening?
We don't change accounts, we also use admin so I know it's not a security issue.
Try adding net use before running the command so it makes that initial connection before pulling the file
Net use \\local\it$ "passwordhere" /USER:domain.username
cd C:\Program Files\Microsoft SQL Server\120\DTS\Binn
dtexec.exe /f "\\local\it$\Development\.NET Projects\Reporting\DailyUpload_DEV\DailyUpload\File.dtsx"

Unable to do a simple rename file in ReleaseManagement during deployment

I have a problem that has been bugging me.
I have a Visual studio 2013 solution that goes through Release management.
One of the release steps in Release management is running a simple batch file using the Actions -> SxSBatchCommand tool. This is a custom action that simply executes a batch file and the batch file executes a simple rename that goes like this:
rename "$(currentDir)\project.ev1.app.config" "project.exe.config"
Which basically takes a specific app.config and applies it in the deployed directory as the main config.
All this works well but because I don't like all the batch files in my project, I decided to delete them and to use the WindowsOS -> Rename File or folder tool
So I deleted the SxSBatchCommand and added the "Rename File or Folder" with parameters:
FileFolderName: project.ev1.app.config
DestinationName: project.exe.config
I also tried:
FileFolderName: $(currentDir)\project.ev1.app.config
DestinationName: project.exe.config
This failed during deployment with the message:
The following command failed with the exit code '1' : powershell -command ./ManageWindowsIO.ps1 -Action Rename -FileFolderName 'project.ev1.app.config' -DestinationName 'project.exe.config'
Any ideas why such a simple command wouldn't be working?
Thanks
Can you run this exact command in powershell console ? You can also click on the button next to the command in the release log to grab a better detaild log whith explanation what went wrong .
The file could be in use , or without proper permissions for modification , you can look for the agent's logs in the target machine .
By the way if you are trying to make a file changed to the name of a configuration file for a win service or want to use transformation in a non web application you can use slow cheetah to accomplish it .

Resources