Problem Using RunWithLogon running Windows software update packages

Started by geauga, August 30, 2019, 12:14:59 PM

Previous topic - Next topic

geauga

I am trying to run a Windows software update package using RunWithLogon.  I am using the wusa.exe and want to do it with the "/quiet" switch.  When I run

RunWithLogon ("wusa.exe c:\data\10.0-kb4512509-x64_3dcaa0cca0554ec2b11491a9633a13b56dc6db1b.msu", " \quiet",  "", @NORMAL, @WAIT, runas_user, runas_domain, runas_pass,1)

I get an error message where the ststem cannont file the specified file.  I assume that it is referencing the msu file.  When I run

RunWithLogon ("wusa.exe", "c:\data\10.0-kb4512509-x64_3dcaa0cca0554ec2b11491a9633a13b56dc6db1b.msu \quiet",  "", @NORMAL, @WAIT, runas_user, runas_domain, runas_pass,1)

I get the wusa help screen.  It seems that the msu file should be a parameter but this does not work.  Any suggestions?







td

You get the file not found error with your first attempt because you can't pass parameters in with the "programname" parameter.  The function does not attempt to parse the contents of the first parameter and there is no executable image by the name "wusa.exe c:\data\10.0-kb4512509-x64_3dcaa0cca0554ec2b11491a9633a13b56dc6db1b.msu" on your system.

Just a wild guess but your second attempt could be failing because wusa.exe cannot find the msu file for some reason because wusa.exe will display its help window when it can't find the file to install.  That is a long name and errors do happen.  If the file path+name are OK then I don't have a good answer for you.

Perhaps you are running on a system without UAC but it seems a bit unusual that you even get the utility to display its help window.  Wusa.exe requires elevation and you can't use RunWithLong to start a process that requires elevation even if you use the function from an elevated process.   The way to run an application that requires elevation and a different user is to use a Bootstrapper script.  An example can be found here:

https://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/nftechsupt.web+WinBatch/UAC+RunWithLogon~and~UAC.txt

The key to using a bootstrapper is to make sure you run the script as a standard user account or as a restricted admin.  To do that you need to compile the script with the UAC setting set to asInvoker and False or changing the script file's extension to .wbt_if when running the script directly.

Obviously, if you are executing your script on a system without UAC and don't plan on running it on a system with UAC enabled you can ignore the Bootstrapper business.
 
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade