I'm trying to make a program, that can start the HP Image Assistant in CLI mode and update the PC. I didn't find a way to make the progress of the updates show up in the command line (I don't think HP programmed it), so now I just try to make it with the /noninteractive argument - this shows at least a progress bar. I've made a process to start cmd.exe and run HPImageAssistant.exe with my arguments. Problem is, that cmd.exe opens HPImageAssistant.exe in the background, and reports cmd.exe as finished instantly, even if the updater is still working. Because of this, my program assumes that cmd.exe is finished and closes it instantly with HPImageAssistant.exe in the background.
my code for this:
Process HPIAAutoUpdater = new Process();
HPIAAutoUpdater.StartInfo.FileName = "cmd.exe";
HPIAAutoUpdater.StartInfo.Arguments = @"HPImageAssistant.exe /Operation:Analyze /Action:Install /Silent /Noninteractive /AutoCleanup /ResultFilePath:C:\Users\" + Environment.GetEnvironmentVariable("USERNAME") + @"\Desktop\HP Software Update Result.html";
HPIAAutoUpdater.StartInfo.WorkingDirectory = @"C:\Program Files (x86)\HP\HP Image Assistant";
HPIAAutoUpdater.StartInfo.CreateNoWindows = true;
HPIAAutoUpdater.StartInfo.UseShellExecute = false;
HPIAAutoUpdater.Start();
HPIAAutoUpdater.WaitForExit();
The command works if I put it manually into cmd, but in my C# code it finishes in milliseconds.
This is a common mistake, you should directly run the program instead of cmd.exe.
HPIAAutoUpdater.StartInfo.FileName = @"C:\Program Files (x86)\HP\HP Image Assistant\HPImageAssistant.exe";
HPIAAutoUpdater.StartInfo.Arguments = @"/Operation:Analyze /Action:Install /Silent /Noninteractive /AutoCleanup /ResultFilePath:C:\Users\" + Environment.GetEnvironmentVariable("USERNAME") + @"\Desktop\HP Software Update Result.html";