toolbar button for "open cmd as admin"
-
- Posts: 1
- Joined: 17 Feb 2017 15:48
toolbar button for "open cmd as admin"
There's a toolbar button for cmd but not for "cmd as admin". Is there any way to open cmd as admin?
Re: toolbar button for "open cmd as admin"
Scripting is (probably) always a solution (Pro version required).
A very old script that I can put on a toolbar button:
On left click it starts the cmd with admin permissions and on right click without...
A very old script that I can put on a toolbar button:
Code: Select all
$comspec = ("%osbitness%" == 64) ? "%windir%\System32\cmd.exe" : "%windir%\SysWOW64\cmd.exe";
$cscript = ("%osbitness%" == 64) ? "%windir%\System32\cscript.exe" : "%windir%\SysWOW64\cscript.exe";
$vbsFile = "%TEMP%\~OpenElevatedCMD.vbs";
$vbsContent = <<<>>>
Set UAC = CreateObject("Shell.Application")
UAC.ShellExecute "$comspec", "/k pushd ""<curpath>""", "", "runas", 1
>>>;
writefile($vbsFile, trim($vbsContent));
if (get("trigger") == "1") { // Left click -> Admin
run """$cscript"" ""$vbsFile"" //nologo", , 0, 0;
} elseif (get("trigger") == "2") { // Right click -> No admin
run """$comspec"" /k pushd ""<curpath>""";
}
One of my scripts helped you out? Please donate via Paypal
-
- Site Admin
- Posts: 60598
- Joined: 22 May 2004 16:48
- Location: Win8.1 @100%, Win10 @100%
- Contact:
Re: toolbar button for "open cmd as admin"
I tried to do this right in the code and it works. I get a box that looks e.g. like this. On demand I could make this available as Miscellaneous function.
- Attachments
-
- AdminBox.png (3.37 KiB) Viewed 2691 times
FAQ | XY News RSS | XY Twitter
Re: toolbar button for "open cmd as admin"
As long as it is the 64-bit cmd prompt on a 64-bit system, it's fine
One of my scripts helped you out? Please donate via Paypal
-
- Site Admin
- Posts: 60598
- Joined: 22 May 2004 16:48
- Location: Win8.1 @100%, Win10 @100%
- Contact:
Re: toolbar button for "open cmd as admin"
Acc. to Task Manager it is the 64-bit cmd prompt.highend wrote:As long as it is the 64-bit cmd prompt on a 64-bit system, it's fine
FAQ | XY News RSS | XY Twitter
Re: toolbar button for "open cmd as admin"
+1 for supporting this. Thanks Don... and THIS is why the Slant poll continues to show XY as the leader: Direct and immediate responses from the Developer! You sir, are gentleman among thieves (and when comparing to DO, that's never been more appropriate!).
-
- Site Admin
- Posts: 60598
- Joined: 22 May 2004 16:48
- Location: Win8.1 @100%, Win10 @100%
- Contact:
Re: toolbar button for "open cmd as admin"
I decided to handle this with a new scripting command: opencommandprompt.
Piece of cake to create a button for it then.
Piece of cake to create a button for it then.
FAQ | XY News RSS | XY Twitter
Re: toolbar button for "open cmd as admin"
Code: Select all
opencommandprompt , , , 1;
But nothing happens. Literally nothing.
Code: Select all
opencommandprompt "C:\", 3:=1;
One of my scripts helped you out? Please donate via Paypal
-
- Site Admin
- Posts: 60598
- Joined: 22 May 2004 16:48
- Location: Win8.1 @100%, Win10 @100%
- Contact:
Re: toolbar button for "open cmd as admin"
Oha!? Both works fine here. Win 8.1
FAQ | XY News RSS | XY Twitter
Re: toolbar button for "open cmd as admin"
Win 7 x64 in an older notebook here. Don't have access to my other systems currently...
One of my scripts helped you out? Please donate via Paypal
Re: toolbar button for "open cmd as admin"
To verify I've just tested both forms in W7pro X64: both work just as expected.
Win11 Pro 223H2 Gerrman
Re: toolbar button for "open cmd as admin"
Both prompts work in Windows 10 x64 .
Windows 11, 23H2 Build 22631.3447 at 100% 2560x1440
Re: toolbar button for "open cmd as admin"
Running version 17.50.0210, if I create a CTB with opencommandprompt; I am getting:
'opencommandprompt' is not a valid script command.
'opencommandprompt' is not a valid script command.
Re: toolbar button for "open cmd as admin"
You need 219^^
One of my scripts helped you out? Please donate via Paypal
Re: toolbar button for "open cmd as admin"
Got 222, now working great, thanks!