Pages

Friday 15 June 2012

Increment ActiveSetup Version - VBScript


'This script will create the Active setup if not present on the system, otherwise it will increment the version of the active setup 


' Need to replace the "Any that you want to run" with the exact path of the EXE/MSI/Script which has to run
' Replace the "<NameOfActiveSetup>" with the related unique application name




Option Explicit
On Error Resume Next
Dim WshShell ,PrgFiles,KeyValue
Set WshShell=CreateObject("WScript.Shell")




KeyValue=WshShell.RegRead("HKLM\SOFTWARE\Microsoft\Active Setup\Installed Components\<NameOfActiveSetup>\Version")


WshShell.RegWrite "HKLM\SOFTWARE\Microsoft\Active Setup\Installed Components\<NameOfActiveSetup>\StubPath", "Any that you want to run"


'Err.Clear


If  Err.Number=0 Then
     
WshShell.RegWrite "HKLM\SOFTWARE\Microsoft\Active Setup\Installed Components\<NameOfActiveSetup>\Version",KeyValue+1,"REG_SZ"   

Else

WshShell.RegWrite "HKLM\SOFTWARE\Microsoft\Active Setup\Installed Components\<NameOfActiveSetup>\Version","1","REG_SZ"

End If




Set WshShell = Nothing
Set PrgFiles = Nothing


WScript.Quit

No comments:

Post a Comment