0

Full script here: https://gist.github.com/sithtoast/92ee19119e73ced8b159f388af4f8892

I am attempting to run an EXE from Powershell in an effort to automate things. The problem I'm running into is that when this certain EXE is called from Powershell, it does not run properly.

Elaborating on "not running properly": There is a stage of the installer that it backs up parts of the registry and fails there. The exact error is as follows -

Could not launch process regedit.exe /s "C:\Program Files\EVault\InfoStage\Director\~registry-1b683bce-c303-4c9b-8ccd-77b750318005\regbackup.reg" (The system cannot find the file specified.), error code: 2

However, when I browse to said EXE manually and run it - it works just fine. Other EXEs that are called the exact same way work as intended.

Start-Process 'C:\Blah\install.exe' -Wait

The script is kicked off in an administrator instance of Powershell. I'm not sure if the installer doesn't like being kicked off by PS or if there is something more screwy going on.

What else can I try?

SithToast
  • 77
  • 7
  • 1
    You don't need `Start-Process`. Just run the executable - type the name of the executable on PowerShell's command line and press `Enter`. – Bill_Stewart Aug 15 '16 at 19:36
  • Right. I'm trying to run this automatically from the script. I have already tried running it with & C:\Blah\install.exe and the installer's behavior did not change. – SithToast Aug 15 '16 at 19:43
  • If the installer spawns a separate executable, then all bets are off. PowerShell will wait for the first one to terminate, but it wouldn't know about any others. – Bill_Stewart Aug 15 '16 at 19:45
  • 2
    Is the installer interactive? Does it require an input file to read answers? – alvits Aug 15 '16 at 19:46
  • Please describe `it does not run properly` what is (not) happening that is not intended? – Will B. Aug 15 '16 at 19:49
  • I just found that just running the EXE from a admin PS prompt (no $ or Start-Process) outside of the script works as intended. – SithToast Aug 15 '16 at 20:54
  • The `PATH` defined in `PS` may not have the correct directories to find `regedit.exe`. Running interactively uses the current session's `PATH`. – alvits Aug 15 '16 at 21:20
  • @alvits It's strange that it works for the other evault setup file in the script. How would I import the PATH so that the file knows where to look for regedit.exe? – SithToast Aug 15 '16 at 22:39
  • Have you checked these 2 http://www.computerperformance.co.uk/powershell/powershell_env_path.htm http://stackoverflow.com/questions/714877/setting-windows-powershell-path-variable? – alvits Aug 15 '16 at 22:59
  • The error message may be saying it can't find the .reg file. But in either case, if this error message is being generated by the installer, then you need to ask the author of the installer what the problem is. – Bill_Stewart Aug 16 '16 at 03:50

0 Answers0