How to run a powershell script in runonce-Key?

Erik picture Erik · Jun 20, 2012 · Viewed 31.4k times · Source

I have a call to powershell.exe that looks like this, and which works from my commandline:

powershell.exe -noexit -command " & 'C:\Test\test.ps1' "

However, when I enter that entry exactly that way in the runonce-key of my current user, nothing happens.

What is the correct way to call powershell.exe passing parameters from runonce or run?

Answer

CB. picture CB. · Jun 20, 2012

Try with full path:

c:\WINDOWS\system32\WindowsPowerShell\v1.0\powershell.exe -noexit "C:\Test\test.ps1" 

or

c:\WINDOWS\system32\WindowsPowerShell\v1.0\powershell.exe -noexit -command " & 'C:\Test\test.ps1' "