Jump to content

Recommended Posts

Posted

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.


Posted

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

Posted

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!

Posted

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.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
  • Recently Browsing   0 members

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