This project is read-only.

Multiple Parameters in the Execute-Process function?

Topics: Archive - General
Jan 8, 2015 at 4:56 PM
Hi all,

I love the idea of the PADT, but I run into an issue:

I want to use the Execute-Process function to call a command like

regedit.exe /s "C:\Users\FirstName Last Name\AppData\local\Temp\HKCU.reg"

with a space in the second path parameter. I already tried different syntax of the command but was not able to get it working. Unfortunately you documentation for release 3.5 contains only a simple example

-Parameters '/s'

for this function.

Is there a way to get this working (it should because you have the -Parameters option for this function) and if yes, how looks the syntax for the example above?

If not I guess I want to report this bug which will hopefully fixed quickly by you ;)

Thank you!
Jan 14, 2015 at 11:36 PM
Hi snruebes. Just another PADT fan here but I think I can help.

First of all, if you want to make registry changes maybe try using the Set-RegistryKey function, or the even cooler Invoke-HKCURegistrySettingsForAllUsers function.

Otherwise, this might work:

Execute-Process "regedit.exe" -Parameters "/s ^"C:\Users\FirstName Last Name\AppData\local\Temp\HKCU.reg^""

Replace the ^ with ` which is an escape character (doesn't display in the forum), that might do the trick.
Jan 15, 2015 at 9:31 AM
Hi ambrosis,

cool tip - this works like a charm! Thank you very much.

I know the HKCURegistrySettingsForAllUsers function - the reason why I decided to not use it in this case although it is of course much more elegant is the fact that I had to set 71 registry key values and to safe time I desided to use one line script code to togehther with an exported reg file instead of calling HKCURegistrySettingsForAllUser 71 times.

I love this tools and the community here!

Happy coding!