如何在新的管理 shell 中轻松执行任何命令?

如何在新的管理 shell 中轻松执行任何命令?

当从开始菜单上的 W7 程序搜索栏打开 cmd 时,是否可以传递另一行以便在打开时运行?

具体来说,我想做的是运行cmd iisreset,因为issreset默认情况下未设置为以管理员身份运行,但cmd设置为,因此当我通过cmd它运行它时,它会以管理员身份运行。目前我必须转到cmd-> Enter-> iisreset->Enter

我知道我可以将 iisreset 更改为始终在管理员下运行(并且很可能会这样做),但只是想知道是否有任何方法可以在开始菜单中仅使用一个命令执行上述操作?(保存设置批处理脚本等,因为我可能希望以相同的方式从 cmd 调用其他 exe)

答案1

  1. 类型cmd /K iisreset
    在此处输入图片描述

  2. Ctrl++ShiftEnter


结果

执行上面描述的步骤将会执行iisreset并将您直接带入管理 shell(用于执行)。

在此处输入图片描述

附加信息

这是命令行文档cmd.exe。我突出显示了与此过程最相关的两个命令行选项。

Starts a new instance of the Windows command interpreter

CMD [/A | /U] [/Q] [/D] [/E:ON | /E:OFF] [/F:ON | /F:OFF] [/V:ON | /V:OFF]
    [[/S] [/C | /K] string]    

/C Carries out the command specified by string and then terminates
/K Carries out the command specified by string but remains

/S      Modifies the treatment of string after /C or /K (see below)
/Q      Turns echo off
/D      Disable execution of AutoRun commands from registry (see below)
/A      Causes the output of internal commands to a pipe or file to be ANSI
/U      Causes the output of internal commands to a pipe or file to be
        Unicode
/T:fg   Sets the foreground/background colors (see COLOR /? for more info)
/E:ON   Enable command extensions (see below)
/E:OFF  Disable command extensions (see below)
/F:ON   Enable file and directory name completion characters (see below)
/F:OFF  Disable file and directory name completion characters (see below)
/V:ON   Enable delayed environment variable expansion using ! as the
        delimiter. For example, /V:ON would allow !var! to expand the
        variable var at execution time.  The var syntax expands variables
        at input time, which is quite a different thing when inside of a FOR
        loop.
/V:OFF  Disable delayed environment expansion.

相关内容