我想通过命令行别名以不同的用户身份启动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 时我可以传入用户名?我想输入: 即MyDomain \ SomeUser 并且runas使用MyDomain \ SomeUser作为/ user变量并提示我输入指定帐户的密码。
答案 0 :(得分: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.