运行 Powershell 作为管理员使用 Terminal Sublime Text 3

Run Powershell as administrator with Terminal Sublime Text 3

如何在 Sublime Text 3 中 运行 PowerShell 作为管理员使用 Terminal

这里是默认配置:

{
    // The command to execute for the terminal, leave blank for the OS default
    // See https://github.com/wbond/sublime_terminal#examples for examples
    "terminal": "",

    // A list of default parameters to pass to the terminal, this can be
    // overridden by passing the "parameters" key with a list value to the args
    // dict when calling the "open_terminal" or "open_terminal_project_folder"
    // commands
    "parameters": [],

    // An environment variables changeset. Default environment variables used for the
    // terminal are inherited from sublime. Use this mapping to overwrite/unset. Use
    // null value to indicate that the environment variable should be unset.
    "env": {}
}

这是一篇使用插件讨论您的用例的文章。

"Wouldn’t it be great if Sublime allowed you to run bash or PowerShell from its popup terminal?"

sublimetexttips.com/how-to-open-terminal-or-powershell-from-your-sublime-project

选项 1: 运行 Sublime Text 作为管理员。由终端插件启动的进程也将在管理员用户下 运行。小心——第三方插件也有管理员权限。

选项 2: 配置终端插件以启动新的 PowerShell 实例,运行作为管理员:

"terminal": "powershell.exe",
"parameters": [
    "-WindowStyle", "Hidden", 
    "-Command", "Start-Process", "-Verb", "RunAs", "powershell.exe",
    "-ArgumentList", "'-NoExit', '-Command', Set-Location, \"'$PWD'\""
],

此配置启动一个命令,以管理员用户身份重新启动 PowerShell。我们手动重置工作目录,因为新实例在不同的进程中启动 space。启用 UAC 后,我们需要在出现提升权限的 UAC 提示符中确认执行。如果需要,我们可以 disable the prompt 为特定程序。