Script to Kill Running Process
I have make a package to uninstall Office Project 2007. It works fine & remove the Project 2007 if any file of Project is not opened. But when I keep open project file and run the uninstall package, it don't remove the package.
So is there any logic or Script to hold the unstall till the project file get closed. And automatically start removing the application once project file closed?
So is there any logic or Script to hold the unstall till the project file get closed. And automatically start removing the application once project file closed?
0 Comments
[ + ] Show comments
Answers (7)
Please log in to answer
Posted by:
suchi.jigar
13 years ago
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set WshShell = CreateObject("WScript.Shell")
WshShell.Run "Taskkill /F /IM sqlservr.exe",1,TRUE
instead of sqlservr.exe, give your exe name which is running and then, give your packages code, else i give you the uninstall script of visual studio 2005, according to it, create your script.
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set WshShell = CreateObject("WScript.Shell")
ProgLoc = WshShell.ExpandEnvironmentStrings("%ProgramFiles%")
Scriptpath = WScript.ScriptFullName
ScriptDir = Left(ScriptPath,InStrRev(ScriptPath, "\",-1, vbTextCompare))
WshShell.Run "Taskkill /F /IM sqlservr.exe",1,TRUE
WshShell.Run "Taskkill /F /IM sqlwriter.exe",1,TRUE
WshShell.Run "msiexec /x {BCC899FE-2DAA-460C-A5FB-60291E73D9C3} /QB!",1,TRUE
WshShell.Run "msiexec /x {2E5C075E-11AB-4BDD-918C-7B9A68953FF8} /QB!",1,TRUE
WshShell.Run "msiexec /x {241F2BF7-69EB-42A4-9156-96B2426C7504} /QB!",1,TRUE
WshShell.Run "msiexec /x {9A33B83D-FFC4-44CF-BEEF-632DECEF2FCD} /QB!",1,TRUE
WshShell.Run "msiexec /x {6C9F6D23-E9AD-43C9-B43A-011562AAF876} /QB!",1,TRUE
WshShell.Run "msiexec /x {9656F3AC-6BA9-43F0-ABED-F214B5DAB27B} /QB!",1,TRUE
WshShell.Run "msiexec /x {AA467959-A1D6-4F45-90CD-11DC57733F32} /QB!",1,TRUE
WshShell.Run chr(34) & "C:\Program Files\Microsoft Visual Studio 9.0\Microsoft Visual Studio 2008 Professional Edition - ENU\setup.exe" & chr(34) & "/remove /q /norestart" ,1,True
WshShell.Run chr(34) & "C:\Program Files\Common Files\Microsoft Shared\VSTO\9.0\Visual Studio Tools for the Office system 3.0 Runtime\install.exe" & chr(34) & "/qu" ,1,True
WshShell.Run chr(34) & "C:\Program Files\Common Files\Microsoft Shared\Help 9\Microsoft Document Explorer 2008\install.exe" & chr(34) & "/qu" ,1,True
WshShell.Run chr(34) & "C:\Program Files\Common Files\Microsoft Shared\OFFICE12\Office Setup Controller\setup.exe" & chr(34) & " /uninstall VISUALWEBDEVELOPER /config " & chr(34) & " C:\Program Files\Microsoft Visual Studio 9.0\VisualWebDev.XML" & chr(34),1,True
WshShell.Run "msiexec /x {B32E7732-B2FB-3FD0-81AC-6025B1104C66} /QB!",1,TRUE
WshShell.Run "msiexec /x {05EC21B8-4593-3037-A781-A6B5AFFCB19D} /QB!",1,TRUE
WshShell.Run "msiexec /x {B268E9A1-04A9-40D0-9866-846BE2B74BA7} /QB!",1,TRUE
WshShell.Run "msiexec /x {842FAF7C-50EF-4463-9B8F-6222E1384D7D} /QB!",1,TRUE
WshShell.Run "msiexec /x {64c5b887-b5ee-42b8-8596-78905a6b5f1f} /QB!",1,TRUE
WshShell.Run "msiexec /x {CAA376AF-0DE8-4FCA-942E-C6AC579B94B3} /QB!",1,TRUE
'WshShell.Run "msiexec /x {4A7FDA4D-F4D7-4A49-934A-066D59A43C7E} /QB!",1,TRUE
'WshShell.Run "msiexec /x {30465B6C-B53F-49A1-9EBA-A3F187AD502E} /QB!",1,True
WshShell.Run "msiexec /x {388E4B09-3E71-4649-8921-F44A3A2954A7} /QB!",1,TRUE
WshShell.Run chr(34) & "c:\Program Files\Microsoft Visual Studio 9.0\unwise.exe" & chr(34) & "/s " & chr(34) & "C:\Program Files\Microsoft Visual Studio 9.0\install.log" & chr(34),1,True
WshShell.RegDelete "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{2750B389-A2D2-4953-99CA-27C1F2A8E6FD}\"
WshShell.RegDelete "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{2AFFFDD7-ED85-4A90-8C52-5DA9EBDC9B8F}\"
WshShell.RegDelete "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{53F5C3EE-05ED-4830-994B-50B2F0D50FCE}\"
WshShell.RegDelete "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{E9F44C98-B8B6-480F-AF7B-E42A0A46F4E3}\"
WshShell.RegDelete "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{F9B3DD02-B0B3-42E9-8650-030DFF0D133D}\"
WshShell.RegDelete "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Microsoft SQL Server 2005\"
objFSO.DeleteFolder("C:\Documents and Settings\All Users\Start Menu\Programs\Microsoft SQL Server 2005")
Set WshShell = CreateObject("WScript.Shell")
WshShell.Run "Taskkill /F /IM sqlservr.exe",1,TRUE
instead of sqlservr.exe, give your exe name which is running and then, give your packages code, else i give you the uninstall script of visual studio 2005, according to it, create your script.
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set WshShell = CreateObject("WScript.Shell")
ProgLoc = WshShell.ExpandEnvironmentStrings("%ProgramFiles%")
Scriptpath = WScript.ScriptFullName
ScriptDir = Left(ScriptPath,InStrRev(ScriptPath, "\",-1, vbTextCompare))
WshShell.Run "Taskkill /F /IM sqlservr.exe",1,TRUE
WshShell.Run "Taskkill /F /IM sqlwriter.exe",1,TRUE
WshShell.Run "msiexec /x {BCC899FE-2DAA-460C-A5FB-60291E73D9C3} /QB!",1,TRUE
WshShell.Run "msiexec /x {2E5C075E-11AB-4BDD-918C-7B9A68953FF8} /QB!",1,TRUE
WshShell.Run "msiexec /x {241F2BF7-69EB-42A4-9156-96B2426C7504} /QB!",1,TRUE
WshShell.Run "msiexec /x {9A33B83D-FFC4-44CF-BEEF-632DECEF2FCD} /QB!",1,TRUE
WshShell.Run "msiexec /x {6C9F6D23-E9AD-43C9-B43A-011562AAF876} /QB!",1,TRUE
WshShell.Run "msiexec /x {9656F3AC-6BA9-43F0-ABED-F214B5DAB27B} /QB!",1,TRUE
WshShell.Run "msiexec /x {AA467959-A1D6-4F45-90CD-11DC57733F32} /QB!",1,TRUE
WshShell.Run chr(34) & "C:\Program Files\Microsoft Visual Studio 9.0\Microsoft Visual Studio 2008 Professional Edition - ENU\setup.exe" & chr(34) & "/remove /q /norestart" ,1,True
WshShell.Run chr(34) & "C:\Program Files\Common Files\Microsoft Shared\VSTO\9.0\Visual Studio Tools for the Office system 3.0 Runtime\install.exe" & chr(34) & "/qu" ,1,True
WshShell.Run chr(34) & "C:\Program Files\Common Files\Microsoft Shared\Help 9\Microsoft Document Explorer 2008\install.exe" & chr(34) & "/qu" ,1,True
WshShell.Run chr(34) & "C:\Program Files\Common Files\Microsoft Shared\OFFICE12\Office Setup Controller\setup.exe" & chr(34) & " /uninstall VISUALWEBDEVELOPER /config " & chr(34) & " C:\Program Files\Microsoft Visual Studio 9.0\VisualWebDev.XML" & chr(34),1,True
WshShell.Run "msiexec /x {B32E7732-B2FB-3FD0-81AC-6025B1104C66} /QB!",1,TRUE
WshShell.Run "msiexec /x {05EC21B8-4593-3037-A781-A6B5AFFCB19D} /QB!",1,TRUE
WshShell.Run "msiexec /x {B268E9A1-04A9-40D0-9866-846BE2B74BA7} /QB!",1,TRUE
WshShell.Run "msiexec /x {842FAF7C-50EF-4463-9B8F-6222E1384D7D} /QB!",1,TRUE
WshShell.Run "msiexec /x {64c5b887-b5ee-42b8-8596-78905a6b5f1f} /QB!",1,TRUE
WshShell.Run "msiexec /x {CAA376AF-0DE8-4FCA-942E-C6AC579B94B3} /QB!",1,TRUE
'WshShell.Run "msiexec /x {4A7FDA4D-F4D7-4A49-934A-066D59A43C7E} /QB!",1,TRUE
'WshShell.Run "msiexec /x {30465B6C-B53F-49A1-9EBA-A3F187AD502E} /QB!",1,True
WshShell.Run "msiexec /x {388E4B09-3E71-4649-8921-F44A3A2954A7} /QB!",1,TRUE
WshShell.Run chr(34) & "c:\Program Files\Microsoft Visual Studio 9.0\unwise.exe" & chr(34) & "/s " & chr(34) & "C:\Program Files\Microsoft Visual Studio 9.0\install.log" & chr(34),1,True
WshShell.RegDelete "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{2750B389-A2D2-4953-99CA-27C1F2A8E6FD}\"
WshShell.RegDelete "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{2AFFFDD7-ED85-4A90-8C52-5DA9EBDC9B8F}\"
WshShell.RegDelete "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{53F5C3EE-05ED-4830-994B-50B2F0D50FCE}\"
WshShell.RegDelete "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{E9F44C98-B8B6-480F-AF7B-E42A0A46F4E3}\"
WshShell.RegDelete "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{F9B3DD02-B0B3-42E9-8650-030DFF0D133D}\"
WshShell.RegDelete "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Microsoft SQL Server 2005\"
objFSO.DeleteFolder("C:\Documents and Settings\All Users\Start Menu\Programs\Microsoft SQL Server 2005")
Posted by:
anonymous_9363
13 years ago
The OP was asking for a script which holds the install until the process is absent (I don't know of a way, other than via the API, for testing for a file lock). Unfortunately, all the script above does is kill the relevant process.Your users will love you for killing the process before they've saved their data...
You may want to explore here http://blogs.msdn.com/windows_installer_team/archive/2006/12/11/windows-installer-and-restart-manager-msi-files-in-use-v2.aspx and research the use of the FilesInUse dialog in general.
@OP, there is a dedicated 'Scripting' forum here on AppDeploy which would probably have been a better place to post your question.
You may want to explore here http://blogs.msdn.com/windows_installer_team/archive/2006/12/11/windows-installer-and-restart-manager-msi-files-in-use-v2.aspx and research the use of the FilesInUse dialog in general.
@OP, there is a dedicated 'Scripting' forum here on AppDeploy which would probably have been a better place to post your question.
Posted by:
gtimlin
13 years ago
If you're not looking to terminate the process and just want to wait until the user closes the application, you can make a VBScript that searches the process list and loops.
You may want to add some code that counts how many loops have been run and then just exit the loop and kill the process after a certain amount of time.
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
bProcessRunning = True
'loop while the process is running
Do While bProcessRunning = True
bProcessRunning = False 'assume the process is not running
Set ProcessList = objWMIService.ExecQuery( "Select * from Win32_Process",,48)
For Each proc in ProcessList
If proc.Name = "msproject.exe" Then 'look for the process name
bProcessRunning = True 'the process is running
End If
Next
WScript.Sleep 1000 'pause for one second
Loop
You may want to add some code that counts how many loops have been run and then just exit the loop and kill the process after a certain amount of time.
Posted by:
anonymous_9363
13 years ago
Posted by:
ramesh111k
13 years ago
Write a script to check the process is running or not and if it is running then it should popup a message that "xxx application is opened. To continue with the installation of advanced version please save and close the project file. Select ok to continue and cancel to quit".
So when the users select ok button then the script should automatically kill the process and continue with the installation. With this users can save and close the project file and continue with the installation. The text message should be changed accordingly.
Ramesh
So when the users select ok button then the script should automatically kill the process and continue with the installation. With this users can save and close the project file and continue with the installation. The text message should be changed accordingly.
Ramesh
Posted by:
fitzgerac
11 years ago

so that the conversation will remain readable.