3

I have the following scenario: I have a script (running on a Linux computer, but that's not very important) that logs on via RDP to multiple Windows 10 machines, brings up an elevated CMD window and types commands in it. Until now, the script was doing it by simulating Windows+X keypress to bring up the menu that appears when right-clicking on Start button, and then pressing "A" for "Command Prompt (Admin)" option (then of course normal UAC window appears, which the script can accept). However, in recent versions of Windows 10 this menu has been changed, and command prompt has been replaced by Powershell. Pressing A now brings up Powershell in admin mode, which is not quite what I want. This can be probably reconfigured, but the script is logging on to multiple machines that I have no direct control over and their configuration should not be changed (these are testbed systems), so reconfiguring this is out of question.

Is there any command or key combination that the script can use to open an elevated CMD window, right from the desktop, Start menu or anything? Just typing cmd and Enter after bringing up the Start menu opens a "normal", non-elevated CMD. Of course if you do it manually, instead of pressing Enter you can after typing cmd mouse over to the found application, right-click and select "Run as administrator", but the script won't be able to identify the mouse position it should move to - keyboard typing is much more reliable.

I want to repeat that I'm looking for something that is available by default - reconfiguring the target machines is out of question. Also, the only way to access the machines is RDP - they are configured so that WMI etc. is not available.

1 Answer 1

3

I already found a solution myself, checked it and it's working :)

After bringing up the Start menu, type cmd and press Ctrl + Shift + Enter instead of just Enter to start CMD as administrator.

Now going to change my scripts :)

4
  • I was going to answer exactly that, but you already found out by yourself... Dec 17, 2020 at 11:30
  • Pin cmd.exe to your taskbar and set the shortcut properties to always run as administrator, assign a hotkey. If you place it in position 0 thru 9 on the taskbar, then you just hit the WinKey and the position number. (if it is a position 1, then WinKey+1)
    – postanote
    Dec 17, 2020 at 21:27
  • Thank you for your sharing!
    – Gloria Gu
    Dec 18, 2020 at 7:24
  • @postanote That would be reconfiguring of a target machine, something that I have specifically excluded. The script needs just to login to machine in it's default state (also the machine might have been reinstalled without my knowledge since I last visited it) and fire up cmd.exe as admin, without any previous preparation on the target machine.
    – raj
    Dec 18, 2020 at 7:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .