VBScript/HTA应用程序-由用户选择一次运行多个程序
这就是我想知道的关于男孩和女孩的事情——首先,我是一个完全不懂这一点的人,我只是刚刚开始,所以不要对我太苛刻。我编写了一系列代码,用于制作.HTA应用程序:VBScript/HTA应用程序-由用户选择一次运行多个程序,vbscript,Vbscript,这就是我想知道的关于男孩和女孩的事情——首先,我是一个完全不懂这一点的人,我只是刚刚开始,所以不要对我太苛刻。我编写了一系列代码,用于制作.HTA应用程序: > <html> <head> > > <script type="text/vbscript"> > > Dim objShell Sub Button1_OnClick() > > if box2.checked AND box1.checked the
> <html> <head>
>
> <script type="text/vbscript">
>
> Dim objShell Sub Button1_OnClick()
>
> if box2.checked AND box1.checked then
>
> Set objShell = CreateObject( "WScript.Shell" )
> objShell.Run("""%programfiles(x86)%\Mozilla Firefox\firefox.exe""")
> Set objShell = Nothing
>
> Set objShell = CreateObject( "WScript.Shell" ) objShell.Run("cmd.exe")
> Set objShell = Nothing
>
> elseif box1.checked then
>
> Set objShell = CreateObject( "WScript.Shell" ) objShell.Run("cmd.exe")
> Set objShell = Nothing
>
> Elseif box2.checked then
>
> Set objShell = CreateObject( "WScript.Shell" )
> objShell.Run("""%programfiles(x86)%\Mozilla Firefox\firefox.exe""")
> Set objShell = Nothing
>
>
> End If End Sub
>
>
> </script> </head> <body> <font face=Calibri> Check the program you
> would like to run! <br> Available programs to run for now: <br> <input
> type="checkbox" name="box1">CMD <br> <input type="checkbox"
> name="box2">Mozilla <br> <i>Choose which program(s) you'd like to run.
> It is possible to run multiple programs at one time!</i></font><br>
> <input type="button" name="btn1" onclick="Button1_OnClick"
> value="Submit"><br> <div id="error"></div>
>
>
>
> </body> </html>
>
>
>
>
>Dim objShell子按钮1_OnClick()
>
>如果选中了box2.0和box1.0,则
>
>设置objShell=CreateObject(“WScript.Shell”)
>运行(“”%programfiles(x86)%\Mozilla Firefox\Firefox.exe“”)
>Set objShell=Nothing
>
>设置objShell=CreateObject(“WScript.Shell”)objShell.Run(“cmd.exe”)
>Set objShell=Nothing
>
>elseif box1.然后检查
>
>设置objShell=CreateObject(“WScript.Shell”)objShell.Run(“cmd.exe”)
>Set objShell=Nothing
>
>Elseif box2.然后检查
>
>设置objShell=CreateObject(“WScript.Shell”)
>运行(“”%programfiles(x86)%\Mozilla Firefox\Firefox.exe“”)
>Set objShell=Nothing
>
>
>如果结束子节点,则结束
>
>
>检查您要安装的程序
>我想跑步
目前可运行的程序:
type=“checkbox”name=“box1”>CMD
name=“box2”>Mozilla
选择要运行的程序。
>一次可以运行多个程序
>value=“Submit”>
>
>
>
>
这就像它应该的那样完美地工作,当我检查两个程序时,它们都会运行,当我检查其中一个时,只有一个会运行。但是如果我在这个列表上有50个不同的程序呢?我想有比为每个程序组合编写if/else/elseif语句更简单的方法来编写它吗?如上所述,我完全不知道这一点,也许我只是还没有发现一个更简单的方法。。。但这也是我问的原因。您可以根据需要使用元素属性
迭代所有复选框,然后使用存储在自定义属性中的路径启动进程(如果选中)。完成。
昏暗的奥布舍尔
设置objShell=CreateObject(“WScript.Shell”)
次启动程序
暗淡复选框
对于Document.getElementsByName(“流程”)中的每个复选框
如果选中复选框,则选中
objShell.Run“”和Checkbox.getAttribute(“路径”)和“”
如果结束
下一个
端接头
检查您要运行的程序
目前可运行的程序:
CMD
Internet Explorer
Firefox
计算器
记事本
选择要运行的程序。一次可以运行多个程序!
如果没有选中任何复选框,您将如何添加显示警告的MsgBox?@WatskeBart