I am using wix and want to call command line after installation.
How can I do this?
My command line is here "bcdedit.exe /set {current} nx AlwaysOff" // this makes dep off
Yes, I've read about custom actions, but I didn't see any example with command line.
P.S. bcdedit is usual exe in Win 7 and higher.
P.S. currently I have next script and it does not work:
Directory ="INSTALLLOCATION"
ExeCommand ='echo hello> echo_test.txt'
Execute ="immediate"
Return ="asyncNoWait"
/>
echo is not an executable, it is the command of the command processor cmd.exe. Change your ExeCommand value to cmd.exe /c "echo hello >echo_test.txt".
Your echo_test.txt would be in an arbitrary directory, you have to use absolute paths to get predictable results.
Ok, this example works...
<CustomAction Id ="echo_test"
Directory ="INSTALLLOCATION"
ExeCommand ='NOTEPAD.EXE echo_test.txt'
Execute ="immediate"
Return ="asyncNoWait"
/>
My test example with echo didn't worked for some reason.
And bcdedit does not exist on WinXP, where I am testing now...
Hi there are lots of example available on net...
try these links
http://wix.sourceforge.net/manual-wix2/qtexec.htm
Execute Command Line In WiX Script?
WiX - CustomAction ExeCommand - Hide Console
Or try this example:
<CustomAction Id="SetQtExecCmd" Property="SetQtExec"
Value=""[PutPathOfThisFileHere]bcdedit.exe" /set {current} nx AlwaysOff" />
<CustomAction Id="SetQtExec" BinaryKey="WixCA" DllEntry="CAQuietExec" Execute="immediate" Return="check" />
Related
I need to run a cmd command during install, so I created a CustomAction which is set to run after InstallFiles.
The command is: Update.exe --someargs
The installer keeps on failing with:
"CustomAction RUN_UPDATE returned actual error code -1" which means nothing to me nor google.
For the sake of experiment, I created another CustomAction which just runs a batch file, and it works.
Here are the 2 CustomActions:
<CustomAction Id="RUN_UPDATE" Directory="APPLICATIONFOLDER" Execute="deferred" Impersonate="yes" ExeCommand="cmd.exe /c "Update.exe"" Return="check" />
<CustomAction Id="RUN_BAT" Directory="APPLICATIONFOLDER" Execute="deferred" Impersonate="yes" ExeCommand="cmd.exe /c "runme.bat"" Return="check" />
I really don't understand why the first one fails while the second one succeeds.
Both Update.exe and runme.bat exist in the APPLICATIONFOLDER
I use Impersonate = yes cause my app is installed in LocalAppDir and doesn't need elevated permissions.
Thanks!
The "Update.exe" application you execute returns -1 on exit. This is considered as error reported by your action, therefore the installer fails the installation. You told the installer to do so by setting Return="check". If the exe returned 0, that would be considered success (your batch file does that). You can ignore the application exit code, using Return="ignore". Or make Update.exe return 0, not -1.
Our problem is that custom actions don't run when using msiexec /i Setup.msi /qn (quiet mode installation without UI). They only run with normal installation with UI.
In our Product.wxs for example, we have defined the following:
<Binary Id="SetupCustomAction" SourceFile="$(var.SetupCustomActions.TargetDir)$(var.SetupCustomActions.TargetName).CA.dll" />
<CustomAction Id="UPDATE_CONFIG" BinaryKey="SetupCustomAction" DllEntry="UpdateConfiguration" Execute="commit" Return="check" Impersonate="no" />
<InstallExecuteSequence>
...
<Custom Action="UPDATE_CONFIG" After="InstallFiles"><![CDATA[NOT Installed AND USEIMPERSONATE="0"]]></Custom>
...
</InstallExecuteSequence>
Do we have to use "Quiet Execution Custom Action", trying this out didn't help though!
Please help!
The obvious explanation is that USEIMPERSONATE has the value 1 so the custom action will not run, but I assume perhaps you are setting it to 0 on the command line.
Apart from that it would be useful to know if the install actually succeeds, because if it normally requires elevation with a UAC prompt then this UAC dialog will not be shown, so the custom action will not run elevated and it will fail. The install might succeed because Commit custom actions run after the install, so "check" is not relevant because the install cannot roll back. If you configure that CA as an install custom action it might fail and roll back the install. So after InstallFiles is also not relevant because it's a Commit CA.
The log should show something.
Okay, I have found the cause of the error and a fix for it: The ALLUSERS OR PREVIOUSINSTALLSCOPE (read from the registry) Properties must be set to "1". That way, the DISABLE_IMPERSONATE Custom Action gets run and sets the USEIMPERSONATE Property to "0". Then UPDATE_CONFIG and other Custom Actions get run.
To sum up, the solution is:
Change DISABLE_IMPERSONATE Property to this: <Custom Action="DISABLE_IMPERSONATE" After="AppSearch"><![CDATA[ALLUSERS=1 OR PREVIOUSINSTALLSCOPE="1"]]></Custom>
Call msiexec like this: msiexec /i Bechtle.A365.Office.Client.msi /qn ALLUSERS=1
Thanks to #Ritmo2k, #Brian Sutherland and #PhilDW for pointing me to the right direction.
I want to call a command line program of OpenOffice in WiX. To do so, I created a custom action, as seen below:
<CustomAction Id="ca_RunOpenOfficeProgram" Return="check" Directory="TARGETDIR" ExeCommand="cmd.exe /K "C:\OpenOffice.org3\program\unopgk.com list --shared"" />
The Custom Action is being run in an Install Execute Sequence:
<InstallExecuteSequence>
<Custom Action="ca_RunOpenOfficeProgram" Before="InstallFinalize" />
</InstallExecuteSequence>
When running the resulting MSI-File, I receive the following error message in a command line:
Invalid command 'C:\OpenOffice.org3\program\unopkg.com' could not be found.
Well, of course, the command is available and I may run it from command line. But it just doesnt work if the command line is being called by WiX.
It`s also notable that the part 'list --shared' is completely ignored.
Does anyone know what`s going on here?
I would recommend using the ShellExecute custom action from the WiX toolset.
Here is the sample code:
<Property Id="WixShellExecTarget" Value="[#myapplication.exe]" />
<CustomAction Id="LaunchApplication" BinaryKey="WixCA" DllEntry="WixShellExec" Impersonate="yes" />
Change the Value of property WixShellExecTarget to cmd.exe /K "C:\OpenOffice.org3\program\unopgk.com list --shared" and it should work.
Are you sure that cmd.exe /K "C:\OpenOffice.org3\program\unopgk.com list --shared" works? It looks like you have the quotes in the wrong place.
And, do you really want the console window kept open (/k)? Does the user have to enter more commands before the installation continues? You might want /c instead. See the help with cmd /?.
But, if there is only one command needed, why not just run the program directly?
ExeCommand=""C:\OpenOffice.org3\program\unopgk.com" list --shared"
Finally, if the above is the only command needed and assuming C:\OpenOffice.org3\program\unopgk.com is a console application, a useless console window will be opened. This can be avoided with WiX's QtExecCmdLine custom action.
If you are running the program to gather information, and it is a console application, you could do:
cmd /c "C:\OpenOffice.org3\program\unopgk.com" list --shared >path\out.txt
and use another custom action to read the file and make decisions on it or show it to the user in a Windows Installer dialog. This would be a better experience than leaving the user with a console window with a blinking prompt that they have to exit out of.
Found the solution for my problem:
1) As written in my answer to Toms post, I had in typo in the command line ... stupid.
2) The quotes regarding the command line call had been misplaced (Toms answer)
3) I found out that running 'unopkg.com' with the 'shared' parameter is only executed when the command line is being run with administration rights. I thought that the attribute 'impersonated="yes"' in my CustomAction would be enough, but it didn`t help.
Guess I have to dig deeper into documentation of WiX regarding UAC.
Also thanks to Ralf. I didnt try his solutions, but you might give it a shot.
I have the following command running at the end of my package install for an application.
<Property Id="WixShellExecTarget" Value="[INSTALLDIR]RCR.VDS.exe" />
<CustomAction Id="LaunchApplication" BinaryKey="WixCA"
DllEntry="WixShellExec" Impersonate="no" />
I can't use [#myApplication] because I run heat on my output folder on my build server so I don't know the auto generated id of my application. Any ideas on how to silently run my application after the install?
The log file shows this for the command line section
******* CommandLine: **********
MSI (c) (30:74) [09:47:14:156]: Note: 1: 2203 2: VDSInstall.msi 3: -2147287038
MSI (c) (30:74) [09:47:14:156]: MainEngineThread is returning 2
Please see: How To: Run the Installed Application After Setup
If you want the custom action called during a silent install add:
<InstallExecuteSequence>
<Custom Action="LaunchApplication" After="InstallFinalize">SOMECONDITION</Custom>
</InstallExecuteSequence>
Note SOMECONDITION should be an expression that checks the EXE is installed and the user wants the program to be launched.
The are a copy things you can consider:
The identifier from heat.exe will be stable. So you can use the ugly identifer in your [#UglyFileId1234abcef45612345asdf] custom action.
a. You could also apply a XSLT to transform the heat output for the executable file's Id to something nicer than the ugly identifier. Depends how readable you want the launch custom action to be.
If you want the executable launched silently then you'll probably want the Quite Execution custom action instead of the Shell execute custom action that "LaunchApplication" uses.
My goal is to create a simple msi package that is supposed to do nothing but running a .bat script located in the same folder with the .msi. I don't need to copy any files on target machine or create folders, etc. I tried to use Wix 3.5 with vb-script which will run .bat i need. The vb-code itself works perfectly, but inside .msi it acts in a strange way - i can see a message box with the 'path', i got no errors, but script doesn't execute .bat.
<Property Id="Launch">
<![CDATA[
Function Main()
Set shell = CreateObject("WSCript.shell")
path = Session.Property("SourceDir")
MsgBox path
shell.Run path & "sample.bat", 0, False
Set shell = Nothing
Main = 1
End Function
]]>
</Property>
<CustomAction Id="Die"
VBScriptCall="Main"
Property="Launch"
Return="check"
Impersonate="yes"/>
<InstallExecuteSequence>
<Custom Action='Die' Before='RegisterProduct'> NOT Installed </Custom>
</InstallExecuteSequence>
I also tried another way:
<Property Id='CMD'>cmd.exe</Property>
<CustomAction Id='LaunchFile' Property='CMD' ExeCommand='[SourceDir]sample.bat' Return='check' Impersonate='yes'/>
But if I put 'notepad.exe' in property - everythings works great, when I use 'cmd.exe' console opens and closes without executing my sample.bat. In case of 'notepad.exe', it shows the content of 'sample.bat'. Could you guys help me out with this?
Try adding /C to ExeCommand
<CustomAction Id='LaunchFile' Property='CMD' ExeCommand='/C [SourceDir]sample.bat' Return='check' Impersonate='yes'/>
Well, that was easy... Actually, everything was ok, but .bat itself was calculating relative paths from %WinDir%\System32\ I just put CD %~dp0 as the first line of my .bat and it started to work properly.