Page 1 of 1

command shell window: start it as admin via user menu F9

Posted: 26 Nov 2009, 14:40
by Georgd
In Win 7, several simple command line commands require higher privileges, e.g. mklink can't be run as ordinary user. Hence, I'd like to be able to start the command shell not only as me, but also as admin. Salamander itself seems not to support this (I searched help & forum). Hence, I tried to solve it via user menu (F9) but failed. Maybe you know a solution?

$(WinDir)\System32\Rundll32.exe shell32.dll,OpenAs_RunDLL as suggested in http://forum.altap.cz/viewtopic.php?f=4 ... hell#p3688 does ask with which application instead of as which user (like the name suggests) to open the command shell .

runas /user:administrator cmd requires 1) to enter a password ech time and 2) to set a password for admin (which is not standard), hence it's not a comfortable solition.

My User Menu entry
Name: CMD as Admin
Command: I don't know yet :(
Arguments: %ComSpec% (this is where cmd.exe is located)
Directory: $(FullPath) (so it shall be called

Re: command shell window: start it as admin via user menu F9

Posted: 26 Nov 2009, 16:38
by Ether
Georgd wrote:$(WinDir)\System32\Rundll32.exe shell32.dll,OpenAs_RunDLL as suggested in http://forum.altap.cz/viewtopic.php?f=4 ... hell#p3688 does ask with which application instead of as which user (like the name suggests) to open the command shell .
Yes, that's the purpose of this function.
Georgd wrote:runas /user:administrator cmd requires 1) to enter a password ech time and 2) to set a password for admin (which is not standard), hence it's not a comfortable solition.
If I'm not mistaken, this is rather different from what you want. You want an elevated (but still running under the current user account) command prompt, but this command gives you a command prompt under the Administrator account (but it is elevated, nevertheless). As far as I know, runas doesn't elevate.

I searched the net for a solution and I found one coming directly from Microsoft. It's called Elevation PowerToys for Windows Vista and it's been modified to work with Windows 7. After you download these two files, extract them, while replacing the old elevate.vbs with the W7-compatible one. Then, calling elevate.cmd with the elevated program binary path as its parameter should work for you perfectly.

One would think that there'd a command for this by now built in the default Windows setup.

Re: command shell window: start it as admin via user menu F9

Posted: 26 Nov 2009, 17:29
by th.
Here's a vbs script to start a cmd shell with admin rights from the user menu:

Code: Select all

Set objArgs = WScript.Arguments
startfolder = objArgs(0)
Set objShell = CreateObject("Shell.Application")
objShell.ShellExecute "cmd.exe", "/k pushd " & startfolder, "", "runas"
Set "$(FullPath)" as the parameter.

Re: command shell window: start it as admin via user menu F9

Posted: 26 Nov 2009, 17:40
by Georgd
Thank you, the script works fine :mrgreen: Don't forget to surround the script location with " if the path contains spaces, see http://yfrog.com/9gcmdasadmininsalamanderp

Re: command shell window: start it as admin via user menu F9

Posted: 26 Nov 2009, 19:13
by th.
BTW: By unchecking the "execute through shell" option you can get rid of the extra shell window.