简体   繁体   English

使用Terminal Sublime Text 3以管理员身份运行Powershell

[英]Run Powershell as administrator with Terminal Sublime Text 3

How can I run PowerShell as administrator with Terminal in Sublime Text 3? 如何在Sublime Text 3中以Terminal作为管理员运行PowerShell?

Here is the default configuration: 这是默认配置:

{
    // 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": {}
}

Option 1: Run Sublime Text as administrator. 选项1:以管理员身份运行Sublime Text。 The process started by the Terminal plugin will run under the administrator user as well. 终端插件启动的过程也将在管理员用户下运行。 Be careful—third-party plugins will also have admin privileges. 小心 - 第三方插件也具有管理员权限。

Option 2: Configure the Terminal plugin to start a new PowerShell instance that runs as an administrator: 选项2:配置终端插件以启动以管理员身份运行的新PowerShell实例:

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

This configuration launches a command that restarts PowerShell under an admin user. 此配置启动一个命令,该命令在admin用户下重新启动PowerShell。 We manually reset the working directory because the new instance starts in a different process space. 我们手动重置工作目录,因为新实例在不同的进程空间中启动。 When UAC is enabled, we'll need to confirm execution within the UAC prompt that appears to escalate privileges. 启用UAC后,我们需要在UAC提示符中确认执行升级权限。 If desired, we can disable the prompt for a specific program. 如果需要,我们可以禁用特定程序的提示

Here is an article that talks to your use case using a plug in. 这是一篇使用插件与您的用例对话的文章。

"Wouldn't it be great if Sublime allowed you to run bash or PowerShell from its popup terminal?" “如果Sublime允许你从弹出终端运行bash或PowerShell,那会不会很棒?”

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM