vbscript - Script does not wait for statement to finish and starts exectuing next line -


i having scenario if application installed, first uninstall older version, install new version.

i have written following piece of code in batch file using vbscript:

set wshshell = wscript.createobject( "wscript.shell" )  set fso = createobject("scripting.filesystemobject")  path="c:\program files\mysetup\my app 3.5" 'path folder     exists = fso.folderexists(path)  if (exists)      wshshell.run "msiexec /qb /x {3d5d4357-217c-49ba-a8e8-00907d631f05}  "   end if     wshshell.run "msiexec /qb /i c:\build\" & msifilename 

i facing issue when execution goes if (exist) block, lets assume application installed, goes inside if block , start uninstall application , runs asynchronously , start executing next line (installing new version) , cause problem "another installation in progress".

all want once goes uninstalling application, should wait until finished, go next line execution (installing newer version).

you need use third parameter of wshshell.run(), set true wait completion of command.

if (exists)      wshshell.run "msiexec /qb /x {3d5d4357-217c-49ba-a8e8-00907d631f05}  " ,0,true end if wshshell.run "msiexec /qb /i c:\build\" & msifilename,0,true 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -