We've moved!

TechKnack.blogspot.com has officially moved to TechKnack.net. You should be redirected in 3-5 seconds. Thank you.

October 10, 2007

Running .msc files with runas

Add this post to Del.icio.us. Del.icio.us (0 saved)

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!

3 comments:

Anonymous said...

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

EterniCode said...

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.

Unknown said...

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?