【问题标题】:RunAs username from variable来自变量的 RunAs 用户名
【发布时间】:2013-05-08 14:05:00
【问题描述】:

我正在编写一个脚本来以不同的用户身份运行 IE。在开始脚本显示输入,我想使用输入值作为用户名。

Option explicit
Dim Input, europe

Input = InputBox("Please type mailbox name")

europe = "EUROPE\" & Input 

Dim oShell
set oShell= Wscript.CreateObject("WScript.Shell")
oShell.Run "RunAs /profile /user:" & europe &  "C:\Program Files\Internet Explorer\iexplore.exe"
WScript.Sleep 100
oShell.Sendkeys Input
oShell.Sendkeys "{ENTER}"
Wscript.Quit

如您所见,用户名在域EUROPE\ 上,密码与用户名相同。

所以用户名应该像这样EUROPE\ & Input,密码应该是& Input

我无法从变量中获取字符串并将其传递给 shell 命令。

【问题讨论】:

    标签: vbscript runas


    【解决方案1】:

    好的,设法做到了。如果你想把变量中的字符串作为用户名,你需要这样写:

    oShell.Run "RunAs /profile /user:" & europe &" ""C:\Program Files\Internet Explorer\iexplore.exe
    

    【讨论】:

      猜你喜欢
      • 2022-08-11
      • 2018-04-01
      • 2018-02-15
      • 1970-01-01
      • 1970-01-01
      • 2011-11-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多