Pass parameters to program started with Runas

Solution 1:

The correct syntax is to include both the target executable and its parameters in double quotes like this:

runas.exe /user:domain\username "perfmon.exe /res"
runas.exe /user:domain\username "perfmon.exe \"argument with spaces\" /res"

More Information: Runas command

Solution 2:

For anyone stumbling upon this while searching for a way to use runas with an application where its own parameters may contain spaces.

The original accepted answer with \" did not work for me.

What works is to put a double quote to actually be able to pass arguments with spaces:

runas.exe /user:domain\username "perfmon.exe ""argument with spaces"" /res"

It is actually explained quite nicely here: https://ss64.com/nt/syntax-esc.html