How to open an elevated cmd using command line for Windows?

后端 未结 23 1645
既然无缘
既然无缘 2020-12-04 06:21

How do I open a elevated command prompt using command lines on a normal cmd?

For example, I use runas /username:admin cmd but the cmd that was opened do

23条回答
  •  心在旅途
    2020-12-04 06:38

    I use nirsoft programs (eg nircmdc) and sysinternals (eg psexec) all the time. They are very helpful.

    But if you don't want to, or can't, dl a 3rd party program, here's another way, pure Windows.

    Short answer: you can while elevated create a scheduled task with elevated privileges which you can then invoke later while not elevated.

    Middle-length answer: while elevated create task with (but I prefer task scheduler GUI):

    schtasks /create /sc once /tn cmd_elev /tr cmd /rl highest /st 00:00
    

    Then later, no elevation needed, invoke with

    schtasks /run /tn cmd_elev
    

    Long answer: There's a lot of fidgety details; see my blog entry "Start program WITHOUT UAC, useful at system start and in batch files (use task scheduler)"

提交回复
热议问题