|
|
茫茫網海中的冷日
發生過的事,不可能遺忘,只是想不起來而已! |
|
恭喜您是本站第 1729580
位訪客!
登入 | 註冊
|
|
|
|
發表者 |
討論內容 |
冷日 (冷日) |
發表時間:2017/5/2 2:17 |
- Webmaster

- 註冊日: 2008/2/19
- 來自:
- 發表數: 15771
|
- [分享]Windows su Command Prompt
- su Command Prompt [duplicate]
Possible Duplicate:(冷日:下面這一串是討論的比較多,也有比較多其他建議和繞道方法,可是因為冷日想討論的是 runas,所以有興趣者,就請自行移駕囉 Is there any 'sudo' command for Windows?
Commands su & sudo could be used to turn whole current terminal session as super user with administration privileges.
What's the corresponding command of Windows CMD ?
I know that I can start CMD as administrator by Right click & Start as Administrator Typing CMD in start search bar the CTRL + SHIFT + ENTER
But I want to evaluate this permission from inside CMD.
The equivalent in Windows is the "runas" command, it is similar to the "sudo" command in unix/linux but you have to specify the user as well. A typical example would be:
runas /user:mymachine\administrator [command]
If your user is is an Administrator you can use your own username like so:
runas /user:myusername ipconfig
To elevate an entire command prompt just put "cmd" in as the command to run, ie:
runas /user:myusername cmd
There may be other ways of doing this, but this is the way I've done it for years and have seen done in corporate scripted environments.
冷日補充:Win10 上的 runas 說明
C:\WINDOWS\system32>runas
RUNAS 使用方法:
RUNAS [ [/noprofile | /profile] [/env] [/savecred | /netonly] ]
/user:<UserName> program
RUNAS [ [/noprofile | /profile] [/env] [/savecred] ]
/smartcard [/user:<UserName>] program
RUNAS /trustlevel:<TrustLevel> program
/noprofile 指定使用者的設定檔不該載入。
這會導致應用程式載入速度更快,
但可能引起一些應用程式運作失常。
/profile 指定應該載入使用者的設定檔。
這是預設值。
/env 使用目前的環境,不用使用者設定的環境。
/netonly 如果指定的認證是供遠端存取時才使用。
/savecred 使用之前由使用者儲存的認證。
/smartcard 當智慧卡提供了認證時使用。
/user <UserName> 格式如下 USER@DOMAIN 或 DOMAIN\USER
/showtrustlevels 顯示可以用來作為 /trustlevel 引數的
信任等級。
/trustlevel <Level> 應該是以下 /showtrustlevels 列舉的
其中之一等級。
program EXE 的命令列。範例如下
範例:
> runas /noprofile /user:mymachine\administrator cmd
> runas /profile /env /user:mydomain\admin "mmc %windir%\system32\dsa.msc"
> runas /env /user:user@domain.microsoft.com "notepad \"my file.txt\""
注意: 只有在提示時,才輸入使用者密碼。
注意: /profile 與 /netonly 不相容。
注意: /savecred 與 /smartcard 不相容。
原文出處:administrator - su Command Prompt - Super User
|
|
|