October 9, 200322 yr 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, iLoopTimeWaitSet WshShell = WScript.CreateObject("WScript.Shell")Set fso = WScript.CreateObject("Scripting.FileSystemObject")set obj = WScript.CreateObject("BlockATL.Block")iLoopTimeWait = 3000Call Main()Set WshShell = NothingSub 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.QuitEnd SubFunction Connect2Window(iTime, sWindowName) Do Until WshShell.AppActivate (sWindowName) WScript.Sleep iTime LoopEnd Functionand I add following lines to runonce.regWindows 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.
October 10, 200322 yr HiI hope this will help, this code tell vbs to wait untill the running App is finishedSet WshShell = WScript.CreateObject("WScript.Shell")ReturnCode = WshShell.Run("%systemdrive%\Install\YourApp.exe /AppSwitch", 1, True)WScript.Quit
October 10, 200322 yr 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.QuitIf you insert this code the script paused till the window disappear!
October 10, 200322 yr Author My Lastest vbsdim WshShell, obj, sysdSet 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.QuitEnd Subbut 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.
October 11, 200322 yr Again, this lineWshShell.Run sysd & "\CDTEMP\apps\MPC\mpcsetup.exe", 1, trueexecute the program(->Run), activates the window(->1) and WAIT till the window dissapear(->true).RTFM ->WSH Documentation
Create an account or sign in to comment