简体   繁体   English

HTA-VBScript-安装程序,但等待安装完成

[英]HTA - VBScript - Install program but wait for installation to complete

If you could give my a hand that would be great? 如果您能帮助我,那会很棒吗?

I have a HTA file nothing to fancy its to install a few programs one by one 我有一个HTA文件,没什么可花钱的,它只能一个接一个地安装一些程序

I have been reading in a few places on how to wait for installation to complete then install the next program but none make sense to me for what i want, also they are saying to use wscript.sleep that would be great but it doesnt work in a HTA right ? 我已经在一些地方阅读了有关如何等待安装完成然后安装下一个程序的信息,但是对于我想要的东西,我都没有任何意义,他们还说使用wscript.sleep会很棒,但是在HTA对吗?

I have firefox, utorrent, symantec antivirus, adobe reader, office 2003 (packaged with KEY already) and a few others. 我有firefox,utorrent,symantec防病毒软件,adobe reader,office 2003(已经与KEY打包在一起)和其他一些软件。

i want to find switches to install silently but thats not important if this code someone is willing to show me works... 我想找到可以静默安装的开关,但是如果有人愿意向我展示此代码,那并不重要...

I hope I make sense ? 我希望我有道理吗?

If you can help me it would be great ? 如果能帮助我,那会很棒吗?

Cheers Pavle. 干杯。

You might find something useful in my answer ( https://stackoverflow.com/a/3742182/128427 ) to this question: How to get an HTA to restart itself? 您可能会在我对以下问题的答案( https://stackoverflow.com/a/3742182/128427 )中找到有用的东西: 如何获取HTA来自动重启?

It uses a VBScript helper to wait for a process to end (the HTA itself) then restarts the HTA. 它使用VBScript帮助程序来等待进程结束(HTA本身),然后重新启动HTA。 You could modify the vbscript instead to wait for a specific process to end (one of your installers), then return control to the HTA which starts the next installer and calls the wait script again. 您可以修改vbscript来等待特定过程结束(您的安装程序之一),然后将控制权交还给HTA,后者将启动下一个安装程序并再次调用等待脚本。

I don't think an HTA can call the WScript.Sleep routine, but there are the setTimeout and setInterval methods in HTA that call a routine after X seconds, or repeatedly call a routine after every X seconds until cancelled. 我不认为HTA可以调用WScript.Sleep例程,但是HTA中有setTimeout和setInterval方法在X秒后调用例程,或者每隔X秒重复调用例程直到取消。 You can use these to check periodically if a process is still running (using WMI Win32_Process as I show in my other answer). 您可以使用它们定期检查进程是否仍在运行(使用WMI Win32_Process,如我在其他答案中所示)。

To process a list of items like this, instead of using a loop to go through a list and pause after each item, you have a central state-machine routine that calls itself every so often to advance the system. 要处理这样的项目列表,您不必使用循环遍历列表并在每个项目之后暂停,而需要一个中央状态机例程,该例程经常调用自身以推进系统。

'!! extremely "pseudo" pseudo-code follows

sub StartSystem()
    state = "next program"
    list = list of programs to install
    AdvanceSystem() 
end sub

sub AdvanceSystem()

    if state = "next program"

        if more items in list
            start next installer
            remove from list (or increment an index)

            set state to "check program"
        else
            set state to "done"

    if state = "check program"

        use WMI to see if process is still running
        if no
            state = "next program"

    if state <> "done"
        setInterval(AdvanceSystem, 5000) ' call again in 5 seconds

end sub


' then somewhere in your HTA interface have a button to start things off
buttonClick = StartSystem()

Using an arrangement like this you may not even need to run a separate VBScript to check the process and sleep. 使用这种安排,您甚至可能不需要运行单独的VBScript来检查进程和睡眠状态。 Also, with this kind of incremental process, you can send output to a DIV somewhere so the user can see progress, whereas when processing things in a loop, output doesn't show up until the whole process has finished. 同样,使用这种增量过程,您可以将输出发送到某个地方的DIV,以便用户可以看到进度,而当在循环中处理事物时,直到整个过程完成才显示输出。 After each pass through AdvanceSystem, the control returns to the HTA level and the system can update itself. 每次通过AdvanceSystem之后,控件都会返回到HTA级别,并且系统可以自我更新。

Let me know if you need a more specific example, I'll try to write something up. 让我知道您是否需要一个更具体的示例,我将尝试写一些东西。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM