Running .msc files with runas
According to Google Analytics, I’ve gotten quite a few search hits regarding running .msc files (such as services.msc) under a Windows Limited User account using runas. I mentioned in a previous post that there was no way to do this without using a workaround. I’m sorry. I was wrong.
Apparently the mmc program accepts command line arguments. Typing “mmc services.msc” brings up…the services dialog! I tested it with a few other msc files in the C:\Windows\system32 folder; some of them work if you provide the name of the file only (such as services.msc), but all will work if you use the absolute path to the file (C:\windows\system32\services.msc).
And the best part…this method works with runas! Just be sure you put quotes around the mmc command:
runas /user:{admin} “mmc {path\to\msc_file}”
Enjoy!
Subscribe via Email Alerts
Subscribe in an RSS reader
What is RSS?
Eternicode on Twitter
Do you know why you need the quotes around the command? I understand how to do it but no idea why i need the quotes. If you know why id be greatful
Sure thing. You have to use quotes around the command (including its parameters), because the command+parameters is itself a string parameter to the runas command. The runas usage message says:
RUNAS [ [/noprofile | /profile] [/env] [/netonly] ] /user:<UserName> program
if the quotes are excluded, then the program to run and its parameters (all separated by spaces) would be seen as separate parameters to the runas command. Therefore, you have to enclose the whole thing in quotes in order to pass the whole thing as one parameter.
How about if you are trying to use ‘runas’ with the WSUS 3 snap-in which has spaces in the path?
The path to the snap-in is “C:\Program Files\Update Services\administrationsnapin\wsus.msc”. I have tried “mmc C:\Program Files\Update Services\administrationsnapin\wsus.msc” but it does not like the space after the word ‘Program’. I have tried substituting %ProgramFiles% but there is still a space after ‘Update’.
Any ideas?
Mel, to use spaces in the path, you need to escape them. It’s been a while since I used the windows command line, but I think putting a backslash (\) before the spaces should escape them, making them interpreted as part of the path.
Mel,
make it look like this, and it will work.
runas /user:name@domain.com \"mmc \\\"C:\\Program Files\\Update Services\\administrationsnapin\\wsus.msc”\\\"
beetlejelly, your example did not work for me.
instead try similar to the following:
%windir%\system32\runas.exe /u:dec\admin-oliveij “mmc \”C:\Program Files\Microsoft SQL Server\80\Tools\BINN\SQL Server Enterprise Manager.MSC”
No need for triple backslashes.
Joe, your example didn\’t work for me until I added a backslash + quote before the final quote. i.e,
runas /savecred /user:domain\user “c:\windows\system32\mmc.exe \”C:\Program Files\Microsoft Configuration Manager Console\AdminUI\bin\adminconsole.msc\”"
Hope this helps.
I was looking for the parameter to connect to the services on a remote computer. I tried some things and found the solution. If you want to directly connect to the services of a remote computer use (mmc.exe) services.msc /computer=”computername”