Quit msi if app running
I'm sure this has been done but I am unable to find it. I need to quit an install if Excel is running. I am using a custom action to determin if excel is running I update a property but am unsure how to stop the install.
0 Comments
[ + ] Show comments
Answers (4)
Please log in to answer
Posted by:
gmorgan618
17 years ago
Posted by:
SeaWall
17 years ago
this is the custom action i wrote in vbscript to check if excel is running.
Dim strComputer, objWMIService, colProcesses, objProcess, running, WshNetwork, objArgs, app
app ="EXCEL.EXE"
strComputer="."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colProcessList = objWMIService.ExecQuery _
("SELECT * FROM Win32_Process WHERE Name = '" & app & "'")
For Each objProcess in colProcessList
session.Property("EXCELRUNNING") = 1
MsgBox (session.Property("EXCELRUNNING"))
Next
it sets the property correctly I am just not sure how to end the install after checking the property.
yes it run in execute immediate.
Dim strComputer, objWMIService, colProcesses, objProcess, running, WshNetwork, objArgs, app
app ="EXCEL.EXE"
strComputer="."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colProcessList = objWMIService.ExecQuery _
("SELECT * FROM Win32_Process WHERE Name = '" & app & "'")
For Each objProcess in colProcessList
session.Property("EXCELRUNNING") = 1
MsgBox (session.Property("EXCELRUNNING"))
Next
it sets the property correctly I am just not sure how to end the install after checking the property.
yes it run in execute immediate.
Posted by:
anonymous_9363
17 years ago
Posted by:
Inabus
17 years ago
You would make the VBScript into a function that you would then call from a custom action. You would also ensure that the custom action is set to check exit codes. An example of the script is below, this will terminate the MSI installation.
Function ExcelRunning()
Dim strComputer, objWMIService, colProcesses, objProcess, running, WshNetwork, objArgs, app, x
x = 0
app ="EXCEL.EXE"
strComputer="."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colProcessList = objWMIService.ExecQuery _
("SELECT * FROM Win32_Process WHERE Name = '" & app & "'")
For Each objProcess in colProcessList
x = x + 1
Next
If x >= 1 Then
ExcelRunning = 1602
Else
ExcelRunning = 0
End If
End Function
You return a 0 to the function to continue the installation and a terminated install if you pass a 1602.
-Save the above vbscript to your desktop
-add a new custom vbscript stored in the binary table
-browse to the desktop vbscript
-In "Script Function" enter in ExcelRunning and ensure that return processing is "synchronus(check exit code)"
Hope that makes sense!
Regards,
P
Function ExcelRunning()
Dim strComputer, objWMIService, colProcesses, objProcess, running, WshNetwork, objArgs, app, x
x = 0
app ="EXCEL.EXE"
strComputer="."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colProcessList = objWMIService.ExecQuery _
("SELECT * FROM Win32_Process WHERE Name = '" & app & "'")
For Each objProcess in colProcessList
x = x + 1
Next
If x >= 1 Then
ExcelRunning = 1602
Else
ExcelRunning = 0
End If
End Function
You return a 0 to the function to continue the installation and a terminated install if you pass a 1602.
-Save the above vbscript to your desktop
-add a new custom vbscript stored in the binary table
-browse to the desktop vbscript
-In "Script Function" enter in ExcelRunning and ensure that return processing is "synchronus(check exit code)"
Hope that makes sense!
Regards,
P
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
so that the conversation will remain readable.