Code: Select all
'Here the program sleeps for 15000 miliseconds
WScript.Sleep(15000)
'This next part runs a path specified EXE
strProgramPath = "C:\Windows\notepad.exe"
set objShell = createobject("Wscript.Shell")
objShell.Run strProgramPath
Code: Select all
' Here the program sleeps for 1000 milliseconds
WScript.Sleep(1000)
'this next part runs a path specified EXE
strProgramPath = "|"
set objShell = createobject("Wscript.Shell")
objShell.Run strProgramPath
Code: Select all
Set oShell = CreateObject("WScript.Shell")
values = Session.Property("CustomActionData")
tokens = Split(values,"|")
' Get the installation directory
strAppDir = tokens(1)
' Set the current directory to APPDIR
oShell.CurrentDirectory = strAppDir
strOldText = "|"
strNewText = tokens(0)
ReplaceInFile "run.vbs", strOldText, strNewText
Function ReplaceInFile(strFileToUse, strOldText, strNewText)
Const ForReading = 1
Const ForWriting = 2
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(strFileToUse, ForReading)
strText = ""
strFile = ""
strText = objFile.ReadAll
objFile.Close
strFile = Replace(strText, strOldText, strNewText)
Set objFile = objFSO.OpenTextFile(strFileToUse, ForWriting)
objFile.WriteLine strFile
objFile.Close
End Function
Code: Select all
[SEARCH]|[APPDIR]
Code: Select all
[#name_of_your_file.exe]|[APPDIR]
Code: Select all
' Here the program sleep for 1000 miliseconds
WScript.Sleep(1000)
'this next part runs a path specified EXE
strProgramPath = "path_of_the_file"
strCMD = CHR(34) & strProgramPath & CHR(34)
set objShell = createobject("Wscript.Shell")
objShell.Run strCMD
Code: Select all
Set oShell = CreateObject("WScript.Shell")
' Get the installation directory
values = Session.Property("CustomActionData")
tokens = Split(values,"|")
' Set the current directory to APPDIR
oShell.CurrentDirectory = tokens(1)
strOldText = "path_of_the_file"
strNewText = tokens(0)
'assuming the first .vbs file is called run.vbs this is how you call the function
ReplaceInFile "run.vbs", strOldText, strNewText
Function ReplaceInFile(strFileToUse, strOldText, strNewText)
Const ForReading = 1
Const ForWriting = 2
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(strFileToUse, ForReading)
strText = ""
strFile = ""
strText = objFile.ReadAll
objFile.Close
strFile = Replace(strText, strOldText, strNewText)
Set objFile = objFSO.OpenTextFile(strFileToUse, ForWriting)
objFile.WriteLine strFile
objFile.Close
End Function