如何切换到具有管理权限

如何切换到具有管理权限

可能重复:
Windows 有“Sudo”命令吗?

我想知道如何在 Windows 的命令行窗口中切换到具有管理权限?有没有类似于 Linux 下“su”或“sudo”的方法?

例如,我被困在这里:

问:>fsutil fsinfo 驱动器

FSUTIL 实用程序要求您具有管理权限。

感谢致敬!


更新:

  1. 我不确定哪里出了问题:

    C:\D>runas /user:Tim "fsutil fsinfo drives"
    Enter the password for Tim:
    Attempting to start fsutil fsinfo drives as user
    

    “蒂姆—思考\蒂姆”......

    C:\D>runas /user:Tim "dir"
    Enter the password for Tim:
    Attempting to start dir as user "TIM-THINK\Tim" ...
    RUNAS ERROR: Unable to run - dir
    2: The system cannot find the file specified.
    

    如果命令最后不带引号,第一个例子会输出runas的帮助文档,第二个例子会输出与带引号相同的内容。

  2. 我还想知道我是否可以在命令行窗口的当前会话中一次性切换到拥有管理权限,就像 Linux 中的“su”一样?

答案1

你可以尝试该RUNAS命令。

Q:>runas /user:Tim "fsutil fsinfo drives"

来自帮助:

C:\> runas /?
RUNAS USAGE:

RUNAS [ [/noprofile | /profile] [/env] [/savecred | /netonly] ]
        /user:<UserName> program

RUNAS [ [/noprofile | /profile] [/env] [/savecred] ]
        /smartcard [/user:<UserName>] program

RUNAS /trustlevel:<TrustLevel> program

   /noprofile        specifies that the user's profile should not be loaded.
                     This causes the application to load more quickly, but
                     can cause some applications to malfunction.
   /profile          specifies that the user's profile should be loaded.
                     This is the default.
   /env              to use current environment instead of user's.
   /netonly          use if the credentials specified are for remote
                     access only.
   /savecred         to use credentials previously saved by the user.
                     This option is not available on Windows Vista Home or Windo
ws Vista Starter Editions
                     and will be ignored.
   /smartcard        use if the credentials are to be supplied from a
                     smartcard.
   /user             <UserName> should be in form USER@DOMAIN or DOMAIN\USER
   /showtrustlevels  displays the trust levels that can be used as arguments
                     to /trustlevel.
   /trustlevel       <Level> should be one of levels enumerated
                     in /showtrustlevels.
   program         command line for EXE.  See below for examples

Examples:
> runas /noprofile /user:mymachine\administrator cmd
> runas /profile /env /user:mydomain\admin "mmc %windir%\system32\dsa.msc"
> runas /env /user:[email protected] "notepad \"my file.txt\""

NOTE:  Enter user's password only when prompted.
NOTE:  /profile is not compatible with /netonly.
NOTE:  /savecred is not compatible with /smartcard.

dir是内置命令。您需要执行:

runas /user:Tim "cmd /c dir"

要以另一个用户身份运行 CMD shell:

runas /user:Tim "cmd"

答案2

在开始菜单中搜索命令提示符,然后右键单击条目->以管理员身份运行。

相关内容