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

Discussion of bugs and problems found in Altap Salamander. In your reports, please be as descriptive as possible, and report one incident per report. Do not post crash reports here, send us the generated bug report by email instead, please.
User avatar
Georgd
Posts: 101
Joined: 24 Jul 2006, 17:13

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

Post 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
Using Salamander since v 1.52
User avatar
Ether
Posts: 1471
Joined: 10 May 2007, 16:08
Location: Czech Republic
Contact:

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

Post 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.
Ελληνικά rulez.
User avatar
th.
Posts: 116
Joined: 04 Sep 2006, 23:09
Location: Germany

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

Post 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.
User avatar
Georgd
Posts: 101
Joined: 24 Jul 2006, 17:13

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

Post 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
Using Salamander since v 1.52
User avatar
th.
Posts: 116
Joined: 04 Sep 2006, 23:09
Location: Germany

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

Post by th. »

BTW: By unchecking the "execute through shell" option you can get rid of the extra shell window.
Post Reply