Jump to content

Run Vbs With Windows Update Method


Recommended Posts

I want a application to be installed by vbscript method,as it hasnt silent switch.So I have to write a vbs named mpc.vbs:

dim WshShell, iLoopTimeWait

Set WshShell = WScript.CreateObject("WScript.Shell")
Set fso = WScript.CreateObject("Scripting.FileSystemObject")
set obj = WScript.CreateObject("BlockATL.Block")
iLoopTimeWait = 3000
Call Main()
Set WshShell = Nothing

Sub Main()
obj.BlockInput()
WshShell.Run ("%systemdrive%\CDTEMP\apps\MPC\mpcsetup.exe")
Connect2Window iLoopTimeWait, "ÕýÔÚ°²×° Media Player Classic ÖÐÎľ«Æ·°æ"
'setup startup
WshShell.SendKeys " "

'choose install location
WScript.Sleep 2000
WshShell.SendKeys " "

'choose codec
WScript.Sleep 2000
WshShell.SendKeys " "

'installation finished
WScript.Sleep 30000
WshShell.SendKeys "F"

'config
Connect2Window iLoopTimeWait, "Media Player Classic ÖÐÎľ«Æ·°æÉèÖÃ"
WScript.Sleep 2000
WshShell.SendKeys " "

obj.UnblockInput()
Wscript.Quit
End Sub

Function Connect2Window(iTime, sWindowName)
Do Until WshShell.AppActivate (sWindowName)
 WScript.Sleep iTime
Loop
End Function

and I add following lines to runonce.reg

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx][HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\zz110]

"1"="%systemdrive%\\CDTEMP\\apps\\MPC\\mpc.vbs"
@="MPC ÖÐÎľ«Æ·°æ(0926)"

I import the runonce.reg and then restart pc to test it,but the vbscript seems not to work---just stop at the first screen of setup.

However if I execute the mpc.vbs manually,it can work as my expect.

Anybody can give me a hand?

Sorry for my poor english speaking,If you want me to tell u more,plz say!Thank you very much.

Link to comment
Share on other sites


Hi

I hope this will help, this code tell vbs to wait untill the running App is finished

Set WshShell = WScript.CreateObject("WScript.Shell")

ReturnCode = WshShell.Run("%systemdrive%\Install\YourApp.exe /AppSwitch", 1, True)

WScript.Quit

Link to comment
Share on other sites

Don't use DOS var in VBScript !

You have to use "Expand Environment", i post in an other thread.

Insert a short pause after run.

You can use a part of the window name:

"Media Play"

Set WshShell = WScript.CreateObject("WScript.Shell")

ReturnCode = WshShell.Run("%systemdrive%\Install\YourApp.exe /AppSwitch", 1, True)

WScript.Quit

If you insert this code the script paused till the window disappear!

Link to comment
Share on other sites

My Lastest vbs

dim WshShell, obj, sysd

Set WshShell = WScript.CreateObject("WScript.Shell")
Set obj = WScript.CreateObject("BlockATL.Block")
sysd = WshShell.ExpandEnvironmentStrings("%systemdrive%")
Call Main()

Sub Main()
WshShell.Run sysd & "\CDTEMP\apps\MPC\mpcsetup.exe", 1, true
WScript.Sleep 10000
WshShell.AppActivate "ÕýÔÚ°²×° Media Player Classic ÖÐÎľ«Æ·°æ"
'setup startup
WshShell.SendKeys " "

'choose install location
WScript.Sleep 2000
WshShell.SendKeys " "

'choose codec
WScript.Sleep 2000
WshShell.SendKeys " "

'installation finished
WScript.Sleep 30000
WshShell.SendKeys "F"

'config
WScript.Sleep 5000
WshShell.AppActivate "Media Player Classic ÖÐÎľ«Æ·°æÉèÖÃ"
WScript.Sleep 2000
WshShell.SendKeys " "

Wscript.Quit
End Sub

but previous problem still exists,vbscript seems not to do sendkeys to auto the job,just run the app setup and then stop at the first page of setup.Run manually is okay,but fails in the windows update method.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...