0

我想通过命令行别名以其他用户身份启动 Internet Explorer。我喜欢使用 AutoRun 注册表设置来调用环境设置脚本的方法。

因此,我为 HKCU\Software\Microsoft\Command Processor 设置了 AutoRun 注册表项 (REG_SZ) 来执行 env.cmd 文件。env.cmd 文件中有一行: DOSKEY ieas=runas /user:user /netonly "C:\Program Files\Internet Explorer\iexplore.exe"

我的问题是是否有办法在 env.cmd 文件中编写 DOSKEY 命令,以便在调用ieas时可以传入用户名?我想输入: ieas MyDomain\SomeUser 并让 runas 使用 MyDomain\SomeUser 作为 /user 变量,并提示我输入指定帐户的密码。

4

1 回答 1

0
DOSKEY ieas=runas /user:$1 /netonly "C:\Program Files\Internet Explorer\iexplore.exe"

根据doskey /?

Edits command lines, recalls Windows commands, and creates macros.

DOSKEY [/REINSTALL] [/LISTSIZE=size] [/MACROS[:ALL | :exename]]
  [/HISTORY] [/INSERT | /OVERSTRIKE] [/EXENAME=exename] [/MACROFILE=filename]
  [macroname=[text]]
...
  macroname           Specifies a name for a macro you create.
  text                Specifies commands you want to record.
...

The following are some special codes in Doskey macro definitions:
$T     Command separator.  Allows multiple commands in a macro.
$1-$9  Batch parameters.  Equivalent to %1-%9 in batch programs.
$*     Symbol replaced by everything following macro name on command line.
于 2015-07-13T15:45:27.527 回答