"%1 is not a valid win32 application" Rust Command run fail - windows

I'm downloading an executable via curl and try to run it afterwards. However, the Command object responsible for running it crashes with the following message: %1 is not a valid Win32 application. (os error 193)
Here's a snippet for better context:
let link = "https://download.bell-sw.com/java/18.0.1.1+2/bellsoft-jre18.0.1.1+2-windows-amd64-full.msi";
Command::new("curl")
.args(["-O", link])
.output()
.unwrap_or_else(|err| panic!("{err}"));
let program = format!("./{}", link.split('/').last().unwrap());
Command::new(program)
.output()
.unwrap_or_else(|err| panic!("{err}"));

A .msi file is not an executable. To install it you need to run msiexec.exe /i "c:\path\to\installer.msi" /qn.
To open the file like Explorer you would have to call the ShellExecute WinApi...

Related

my clion run default"CreateProcess error=216"

Error running 'random': Cannot run program "C:\Users\31665\CLionProjects\random\cmake-build-debug\random.exe" (in directory "C:\Users\31665\CLionProjects\random\cmake-build-debug"): CreateProcess error=216, 该版本的 %1 与你运行的 Windows 版本不兼容。请查看计算机的系统信息,然后联系软件发布者。enter image description here

CMake: download and run msi

Using kitware's CMake, is it possible to automatically download a Microsoft installer (MSI) file and execute it (on Windows, of course)?
It generally should be. However, clearly running the installer will block the CMake process until the user completes all the required inputs to the installer.
Here's an example for 7-zip's installer making use of file(DOWNLOAD ...) and execute_process:
set(DownloadedMsi ${CMAKE_BINARY_DIR}/7z920-x64.msi)
file(DOWNLOAD http://sourceforge.net/projects/sevenzip/files/7-Zip/9.20/7z920-x64.msi/download
${DownloadedMsi}
TIMEOUT 30
STATUS StatusVar
LOG LogVar
EXPECTED_HASH SHA1=4173fea2af9a595fa0be1ef8251f412229687be1)
message("\${StatusVar} - ${StatusVar}")
message("\${LogVar} - ${LogVar}\n\n\n")
execute_process(COMMAND cmd /c "${DownloadedMsi}"
RESULT_VARIABLE ResultVar
OUTPUT_VARIABLE OutputVar
ERROR_VARIABLE ErrorVar)
message("\${ResultVar} - ${ResultVar}")
message("\${OutputVar} - ${OutputVar}")
message("\${ErrorVar} - ${ErrorVar}")

passing msiexec command line params to a child process started by msiexec

I have a requirement to update config files with the command line provided arguments for some reason, the file is not being updated so I wrote a small utility app in c# to be started by msiexec. The intention is to get the commandline params to this app so that it would open the config file and update it during the course of installation.
My app was executed fine but when trying to read the parent process (msiexec) command line params, I get something like C:\windows\msiexec /V not the ones I specify on the msiexec command line (I'm not even using /V)
Any ideas about what could be the issue? If you have a better way to handle this please suggest.
Thanks.
Update:
Sorry for the confusion, I was using WiX installer and I start the WiX generated .msi on the command line as below for eg.
C:\> msiexec /I foo.msi ARG1="v1" ARG2="v2"
ARG1 and ARG2 are defined in Wix installer script.
What I'm looking at is a way to access the command line params ARG1="v1", ARG2="V" by a small application which will be started by msiexec (the app is specified in Wix installer script as custom action).
Ideally, when I use xmlFile (tried xmlConfig as well), my WiX installer script should be able to update my config files with v1, v2 but its not happening so wrote an application that should be able to read v1 & v2 and write to the config file.
using xmlFile I get the following error:
ExecXmlFile: Error 0x8007006e: failed to load XML file: Error 25531. Failed to open XML file , system error: -2147024786 MSI (s) (E4!54) [18:11:36:714]: Product: -- Error 25531. Failed to open XML file , system error: -2147024786 –
Doesn't get any meaningful info. I used the msiexec argument /l*v to generate the logging.
Log excerpt:
Actually xmlFile should do my requirement but I get the following error while using it. Any help on this would be greatly appreciated.
MSI (s) (E4:00) [18:11:32:110]: Executing op: ActionStart(Name=ExecXmlFile,,) Action 18:11:32: ExecXmlFile.
MSI (s) (E4:00) [18:11:32:111]: Executing op: CustomActionSchedule(Action=ExecXmlFile,ActionType=3073,Source=BinaryData,Target=ExecXmlFile,CustomActionData=1030//cloudRecognition/connectiontype130//cloudRecognition/connectionaddress192.168.128.59;192.168.128.261030//cloudRecognition/connectionport50001;50001)
MSI (s) (E4:DC) [18:11:32:113]: Invoking remote custom action. DLL: C:\Windows\Installer\MSIA419.tmp, Entrypoint: ExecXmlFile
MSI (s) (E4:EC) [18:11:32:113]: Generating random cookie.
MSI (s) (E4:EC) [18:11:32:115]: Created Custom Action Server with PID 10104 (0x2778).
MSI (s) (E4:68) [18:11:32:402]: Running as a service.
MSI (s) (E4:68) [18:11:32:403]: Hello, I'm your 32bit Elevated custom action server.
ExecXmlFile: Error 0x8007006e: failed to load XML file:
Error 25531. Failed to open XML file , system error: -2147024786
MSI (s) (E4!54) [18:11:36:714]: Product: -- Error 25531. Failed to open XML file , system error: -2147024786
CustomAction ExecXmlFile returned actual error code 1603 (note this may not be 100% accurate if translation happened inside sandbox)
Are you passing the arguments as MSI properties? If yes, then you can read them from the MSI database. Check this:
http://www.alteridem.net/2008/05/20/read-properties-from-an-msi-file/
I am guessing you are setting environment specific application properties to the Config file? If so, why don't you have all the properties defined in the config file and make the application smart enough to read the right properties (by checking the environment)? I would do that.
Above comments are just based on the limited information you provided. You would have your own reasons to do so :)
It seems to me that you need to add a CustomAction to your install process.
You might need both or just one, depending of the request that you have.
To Update Configuration files can you use XmlFile CustomAction, to change modify any XML file.
To launch a Quiet Execution CustomAction
I believe that this will allow you to change the values of the configuration file during the installation. You can find a nice introduction to CustomActions and their types here. Have a look at the type 2 CustomAction.
 
Edit for follow question in Answer section:
When is the CA scheduled to launch during the installation process?
Do you have a log file for the install?
 
Re-edit
Without Code or more information about the installation process, I can't really help more.
Helpfull info would be:
Where in the installation sequence is your CA launched?
What WiX Element are you using to change the values in your file.
Did you try to create an installer that does just the part that you are having trouble with, to isolate the behavior.

Windows 7: unable to register DLL - Error Code:0X80004005

When I tried to register a COM DLL,
regsvr32 rpcrt4.dll
I get the following error message:
`The module "c:\windows\system 32\"rpcrt4.dll" was loaded but the call to DllRegisterServer failed with error code 0X80070006.
How do I fix this problem? Please help.
According to this: http://www.vistax64.com/vista-installation-setup/33219-regsvr32-error-0x80004005.html
Run it in a elevated command prompt.
Open the start menu and type cmd into the search box
Hold Ctrl + Shift and press Enter
This runs the Command Prompt in Administrator mode.
Now type regsvr32 MyComobject.dll
Use following command should work on windows 7. don't forget to enclose the dll name with full path in double quotations.
C:\Windows\SysWOW64>regsvr32 "c:\dll.name"

Custom debug command in Visual Studio using a Makefile project

I have a Makefile-powered project in Visual Studio 2010 (uses NAnt, in fact, but that's beside the point).
The output of the build process is a .elf file, and I have a separate, non-VStudio debugger which can be run on that .elf file to debug it.
Building works fine, but when I click the 'debug' button (little green triangle), VStudio fails with "Unable to start program 'XXX.elf'. The specified file is an unrecognized or unsupported binary format"
I'm guessing VStudio is just trying to 'run' the .elf as though it were an .exe, and failing.
What I really want VStudio to do is run "my_debugger.exe XXX.elf" when I press the debug button.
I have tried adding a file association with .elf=>my_debugger.exe
I have updated PATHEXT appropriately as well, and run VStudio under those changes.
Still no luck.
Isn't there somewhere in VStudio where you can specify a custom debug command? I thought there was, but can't find it.
I could just have the build process output a .bat file or something I guess, but this seems silly.
As Jim mentioned you can specify which app to start on run in the project settings (Command field). If you place a debugger there you can pass down your executable as an argument to the debugger being launched (Command Arguments field). This way you can launch the debugger which in turn will launch your executable if the debugger expects any commandline arguments.
MinGW on Windows example:
Command: gdb.exe; Command Arguments: Path\ToMyApp\whatever.exe
will start gdb.exe, gdb.exe will open whatever.exe, parse the debug info and wait for debug instructions.
Command: msys.exe; Command Arguments: gdb.exe Path\ToMyApp\whatever.exe
will start msys.exe, msys.exe will execute "gdb.exe Path\ToMyApp\whatever.exe"
Look at the project properties. Do you have a Debug tab which has a Start Action section giving three choices? Those choices would be: ( ) Start project, (x) Start external program: ... ( ) Start browser with URL.
You can also set the command line arguments and working directory.
Cf. How to: Change the Start Action for Application Debugging

Resources