各位大佬,问个命令行问题
source link: https://www.v2ex.com/t/822679
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
已经打开了 powershell 或 cmd 的情况下,可以提升到管理员权限(像右键选择以管理员打开 powepowershell 或 cmd )吗?
可以的话是什么命令?
monkey110 21 小时 12 分钟前
codergrowing 20 小时 56 分钟前
http://blog.lukesampson.com/sudo-for-windows
```
# first download scoop
iex (new-object net.webclient).downloadstring('https://get.scoop.sh')
# enable powershell, if you haven't already
set-executionpolicy unrestricted -s cu -f
scoop install sudo
```
ncepuzs 20 小时 52 分钟前
flynaj 17 小时 46 分钟前 via Android
flynaj 17 小时 46 分钟前 via Android
ysc3839 16 小时 49 分钟前
弹出 UAC 授权提示的原理之一是调用 ShellExecute ,把 Operation 参数设置成 "runas"。https://docs.microsoft.com/en-us/windows/win32/api/shellapi/nf-shellapi-shellexecutew#runas
PowerShell 可以用 Start-Process -Verb RunAs ,也可以直接调用 ShellExecute API 。
cmd 不能直接调用 Win32 API ,间接的方案可以利用 mshta.exe 通过 URL 执行 VBScript 或 JScript ,创建 "Shell.Application" 对象,然后调用其中的 ShellExecute ,传入 "runas"。
mshta vbscript:CreateObject("Shell.Application").ShellExecute("","","","runas",1)(window.close)
ysc3839 16 小时 47 分钟前
mshta vbscript:CreateObject("Shell.Application").ShellExecute("程序名称","","","runas",1)(window.close)
Tumblr 8 小时 57 分钟前
2. 用 PowerShell 的 Start-Proces 加-Verb RunAs 参数(推荐后者)。
另外,对 @codergrowing #2 提到的 sudo 的内容好奇,怎奈没找到代码,不知道有人在用没,是否可以分享一下。
chengyiqun 8 小时 32 分钟前
不过我更习惯这样
![image.png]( https://s2.loli.net/2021/12/17/zBoPpdrR7yiAkJq.png)
参考 github 上的 windowsterminal-shell
Tumblr 7 小时 53 分钟前
@chengyiqun #10 这个确实也方便,不过在 Windows 11 里又是个 challenge 😌
xingchen23 6 小时 8 分钟前
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK