2

我在 VBScript 中创建了一个登录脚本,但我想添加一种在按下某个键时停止的方法。

该脚本当前加载我们的 citrix 桌面并设置了一些映射驱动器,但我想添加一个 if 语句,例如:

If keyPressed(F10) not true Then

不幸的是,这超出了我的能力范围。

4

1 回答 1

2

AFAIK VBScript doesn't support asynchronous polling for a key-press. There may be different means to the same end, though.

For one thing, you could make the script a startup script (i.e. a shortcut in a startup folder). That way your users could skip over it by pressing Shift at logon (until the desktop icons appear). The downside of this approach is that it doesn't skip selectiveley. Either all startup shortcuts are executed, or none.

Another (perhaps more suitable) way might be the Popup method.

Set sh = CreateObject("WScript.Shell")

loadCitrix = sh.Popup("Load Citrix Desktop?", 10, , vbYesNo + vbQuestion)

Select Case loadCitrix
  Case -1, vbYes : ...
  Case vbNo      : ...
End Select

This will display a popup message for 10 seconds and then proceed with either the value of the pressed button or the default (-1 means "no button was pressed").

于 2013-04-13T22:38:52.113 回答