带VBScript的菜单 [英] Menu with VBScript
问题描述
Hello Scripting Guy!,
Hello Scripting Guy!,
          已经关注您的博客和网站一段时间了,并且发现它非常有用并解决了我的一些问题。 我知道寻求你的智慧,因为我想要完成的事情令我感到困惑。
我知道这很容易,但我知道我错过了什么。 我有一个VBS脚本,我将在一些软件安装结束时调用,这将作为安装程序,它们所在的部门。我可以弹出选择框
,他们可以输入他们的部门的数字,然后单击确定,这是所有工作查找,但我需要做的是单击确定我需要脚本然后运行regedit并导入我生成的正确的reg文件,以便它将导入正确的
计算机上的设置。 下面我附上了菜单的脚本。
Been following your blog and site for awhile now and have found it extremely helpful and has solved quite a few of my problems. I know seek your wisdom as what I am trying to accomplish is baffling me. I know that it is easy but I know that I am missing something. I have a VBS script that I am going to call at the end of some software installation that will as the installer what Department that they are in. I can get the selection box to pop up and they can enter in the number for their dept and click ok that is all working find but what I need to do is upon clicking ok I need the script then run regedit and import the correct reg file that I have generated so that it will import the correct settings on their computer. Below I have attached my script for the menu.
Dim strMsg,inp01,strTitle,strFlag
strTitle =" ;部门。电话簿安装"
$
strMsg ="输入1表示急症护理" &安培; vbCR
strMsg = strMsg& "为PVS输入2" &安培; vbCR
strMsg = strMsg& "为Tele输入3" &安培; vbCR
strFlag = False
Do strFlag = False
inp01 = InputBox(strMsg,"请选择要安装的电话簿")
选择案例inp01
  ;  案例"1"
      MsgBox"你选择急症护理!",64,strTitle
      strFlag = True
 案例"2"
      MsgBox"你选择了PVS!",64,strTitle
      strFlag = True
 案例"3"
      MsgBox"你选择了Tele!",64,strTitle
      strFlag = True
  Case Else
      MsgBox"你的选择不正确!",64,strTitle
结束选择
循环
Wscript.Quit
Dim strMsg,inp01,strTitle,strFlag
strTitle = "Dept. Phonebook Installation"
strMsg = "Enter 1 for Acute Care" & vbCR
strMsg = strMsg & "Enter 2 for PVS" & vbCR
strMsg = strMsg & "Enter 3 for Tele" & vbCR
strFlag = False
Do While strFlag = False
inp01 = InputBox(strMsg,"Please Select Phonebook to Install")
Select Case inp01
Case "1"
MsgBox "You picked Acute Care!",64,strTitle
strFlag = True
Case "2"
MsgBox "You picked PVS!",64,strTitle
strFlag = True
Case "3"
MsgBox "You picked Tele!",64,strTitle
strFlag = True
Case Else
MsgBox "You made an incorrect selection!",64,strTitle
End Select
Loop
Wscript.Quit
我假设它将是某种类型的Elseif声明? 我在另一个脚本上有另一部分代码,我认为这与调用我在这里包含的regedit的方式相同。 我找不到任何可以得到我想要的
的例子。
I am assuming that it will be an Elseif statement of some sort? I have another part of code on a different script that I asuming will be the same way to call regedit which I have included here. I just can't find any examples that will get what I want.
WScript.Echo"在这里输入文字"& vbCrLf
WScript.Sleep(2000)
oShell.Run" regedit / S somefile.reg",0,True
WScript.Echo "Enter Text Here"& vbCrLf
WScript.Sleep (2000)
oShell.Run "regedit /S somefile.reg",0, True
感谢您的帮助。
推荐答案
您的脚本存在一些小问题,例如
There are a few minor problems with your script, e.g.
- 调用布尔变量"strFlag"是一个坏主意,因为它让每个人都感到困惑。
- 使用"regedit.exe"也不好。如果可以使用VB Script命令修改注册表,为什么要向控制台发出声明?
- 您必须为用户提供终止循环的方法,而无需输入正确的选择。
- 正确的代码缩进使得理解脚本结构变得更加容易。
试试这个版本:
strTitle = "署。电话簿安装"
strMsg ="输入1表示急症护理" &安培; vbCr
strMsg = strMsg& "为PVS输入2" &安培; vbCR
strMsg = strMsg& "为Tele输入3" &安培; vbCR
做
inp01 = InputBox(strMsg,"请选择要安装的电话簿")
OK = True
选择案例inp01
案例"1"
MsgBox"你选择急症护理!",64,strTitle
案例"2"
MsgBox"你选择了PVS!",64,strTitle
案例"3"
MsgBox"你选择了Tele!",64,strTitle
案例""
WScript.quit
Case Else
MsgBox"你的选择不正确!",64,strTitle
  OK = False
结束选择
循环但不正常
设置oWshShell = CreateObject(" ; WScript.Shell")
sKey =" HKCU \Control Panel \Desktop\WindowMetrics \"
iHor = -1200
oWshShell.RegWrite sKey& sHor,iHor
strTitle = "Dept. Phonebook Installation"
strMsg = "Enter 1 for Acute Care" & vbCr
strMsg = strMsg & "Enter 2 for PVS" & vbCR
strMsg = strMsg & "Enter 3 for Tele" & vbCR
Do
inp01 = InputBox(strMsg,"Please Select Phonebook to Install")
OK = True
Select Case inp01
Case "1"
MsgBox "You picked Acute Care!",64,strTitle
Case "2"
MsgBox "You picked PVS!",64,strTitle
Case "3"
MsgBox "You picked Tele!",64,strTitle
Case ""
WScript.quit
Case Else
MsgBox "You made an incorrect selection!",64,strTitle
OK = False
End Select
Loop While Not OK
Set oWshShell = CreateObject("WScript.Shell")
sKey = "HKCU\Control Panel\Desktop\WindowMetrics\"
iHor = -1200
oWshShell.RegWrite sKey & sHor, iHor
这篇关于带VBScript的菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!