Lucian Cain
08-09-2006, 01:02 PM
I am attempting to close a running .exe file. (SQLSERVR.EXE) I need to terminate or close down the .exe before i delete the folder where the file lives. (i am removing a previous version of a software package before installing a new version using Autoplay) I can find no way to close a running application. after it closes the application, I will delete the associated files, folders, shortcut, and registry keys. Here is what i have started with... any suggestions?
Code = Dialog.Input("Verification Code", "NOTE: This uninstall procedure works ONLY with WINDOWS XP and WINDOWS 2000. Please enter the code given to you by AccuShade Support.", "", MB_ICONEXCLAMATION);
if Code == "5TGBHU8" then
StatusDlg.Show(MB_ICONNONE, false)
SQLresult = File.IsInUse("c:\\Program Files\\Microsoft SQL Server\\MSSQL\\Binn\\sqlservr.exe");
if SQLresult == true then
File.Rename("C:\\Program Files\\Microsoft SQL Server\\MSSQL\\Binn\\sqlservr.exe", "C:\\Program Files\\Microsoft SQL Server\\MSSQL\\Binn\\sqlserver.old");
File.Delete("C:\\Program Files\\Microsoft SQL Server\\MSSQL\\Binn\\sqlserver.old");
else
File.Delete("C:\\Program Files\\Microsoft SQL Server\\MSSQL\\Binn\\sqlservr.exe");
end
Shell.DeleteShortcut(Shell.GetFolder(SHF_DESKTOP), "AccuShade Color Retrieval System", nil);
Folder.DeleteTree("C:\\Program Files\\Matrix", nil);
Folder.DeleteTree("C:\\Program Files\\Microsoft SQL Server", nil);
Folder.DeleteTree("C:\\Program Files\\MSSQL7", nil);
Folder.DeleteTree("C:\\Documents and Settings\\All Users\\Start Menu\\Programs\\Matrix System", nil);
Registry.DeleteKey(HKEY_CURRENT_USER, "Software\\Plexus Systems LLC", nil);
Registry.DeleteKey(HKEY_CURRENT_USER, "Software\\Microsoft\\Microsoft SQL Server", nil);
Registry.DeleteKey(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Unin stall\\InstallShield Uninstall Information", nil);
Registry.DeleteKey(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Unin stall\\InstallShield_{401BC821-2FFC-4FC3-981A-74D3D88AE3B3}", nil);
Registry.DeleteKey(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Unin stall\\InstallShield_{821FDAAB-B416-41B9-918A-ECCC2D86636C}", nil);
Registry.DeleteKey(HKEY_LOCAL_MACHINE, "SOFTWARE\\Plexus Systems LLC", nil);
Registry.DeleteKey(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Microsoft SQL Server", nil);
Registry.DeleteKey(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Microsoft SQL Server Setup{E09B48B5-E141-427A-AB0C-D3605127224A}", nil);
Registry.DeleteKey(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Microsoft SQL Server Setup.{EFB70B01-B1F3-4960-AB69-4A280084A60C}", nil);
Registry.DeleteKey(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\MSSQLServer", nil);
Registry.DeleteKey(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Unin stall\\{689404D2-1C94-44B3-9203-BEC5594FDA7A}", nil);
Registry.DeleteKey(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Unin stall\\{821FDAAB-B416-41B9-918A-ECCC2D86636C}", nil);
Registry.DeleteKey(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Unin stall\\{401BC821-2FFC-4FC3-981A-74D3D88AE3B3}", nil);
Registry.DeleteKey(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Unin stall\\{E09B48B5-E141-427A-AB0C-D3605127224A}", nil);
Registry.DeleteKey(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Unin stall\\InstallShield Uninstall Information", nil);
StatusDlg.Hide();
Application.Exit(0);
-- If an error occurred, display the error message.
error = Application.GetLastError();
if (error ~= 0) then
Dialog.Message("Error", _tblErrorMessages[error] "Please contact AccuShade software support at (877) 422-2823 and report this error code.", MB_OKCANCEL, MB_ICONEXCLAMATION, MB_DEFBUTTON1);
end
end
Code = Dialog.Input("Verification Code", "NOTE: This uninstall procedure works ONLY with WINDOWS XP and WINDOWS 2000. Please enter the code given to you by AccuShade Support.", "", MB_ICONEXCLAMATION);
if Code == "5TGBHU8" then
StatusDlg.Show(MB_ICONNONE, false)
SQLresult = File.IsInUse("c:\\Program Files\\Microsoft SQL Server\\MSSQL\\Binn\\sqlservr.exe");
if SQLresult == true then
File.Rename("C:\\Program Files\\Microsoft SQL Server\\MSSQL\\Binn\\sqlservr.exe", "C:\\Program Files\\Microsoft SQL Server\\MSSQL\\Binn\\sqlserver.old");
File.Delete("C:\\Program Files\\Microsoft SQL Server\\MSSQL\\Binn\\sqlserver.old");
else
File.Delete("C:\\Program Files\\Microsoft SQL Server\\MSSQL\\Binn\\sqlservr.exe");
end
Shell.DeleteShortcut(Shell.GetFolder(SHF_DESKTOP), "AccuShade Color Retrieval System", nil);
Folder.DeleteTree("C:\\Program Files\\Matrix", nil);
Folder.DeleteTree("C:\\Program Files\\Microsoft SQL Server", nil);
Folder.DeleteTree("C:\\Program Files\\MSSQL7", nil);
Folder.DeleteTree("C:\\Documents and Settings\\All Users\\Start Menu\\Programs\\Matrix System", nil);
Registry.DeleteKey(HKEY_CURRENT_USER, "Software\\Plexus Systems LLC", nil);
Registry.DeleteKey(HKEY_CURRENT_USER, "Software\\Microsoft\\Microsoft SQL Server", nil);
Registry.DeleteKey(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Unin stall\\InstallShield Uninstall Information", nil);
Registry.DeleteKey(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Unin stall\\InstallShield_{401BC821-2FFC-4FC3-981A-74D3D88AE3B3}", nil);
Registry.DeleteKey(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Unin stall\\InstallShield_{821FDAAB-B416-41B9-918A-ECCC2D86636C}", nil);
Registry.DeleteKey(HKEY_LOCAL_MACHINE, "SOFTWARE\\Plexus Systems LLC", nil);
Registry.DeleteKey(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Microsoft SQL Server", nil);
Registry.DeleteKey(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Microsoft SQL Server Setup{E09B48B5-E141-427A-AB0C-D3605127224A}", nil);
Registry.DeleteKey(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Microsoft SQL Server Setup.{EFB70B01-B1F3-4960-AB69-4A280084A60C}", nil);
Registry.DeleteKey(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\MSSQLServer", nil);
Registry.DeleteKey(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Unin stall\\{689404D2-1C94-44B3-9203-BEC5594FDA7A}", nil);
Registry.DeleteKey(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Unin stall\\{821FDAAB-B416-41B9-918A-ECCC2D86636C}", nil);
Registry.DeleteKey(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Unin stall\\{401BC821-2FFC-4FC3-981A-74D3D88AE3B3}", nil);
Registry.DeleteKey(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Unin stall\\{E09B48B5-E141-427A-AB0C-D3605127224A}", nil);
Registry.DeleteKey(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Unin stall\\InstallShield Uninstall Information", nil);
StatusDlg.Hide();
Application.Exit(0);
-- If an error occurred, display the error message.
error = Application.GetLastError();
if (error ~= 0) then
Dialog.Message("Error", _tblErrorMessages[error] "Please contact AccuShade software support at (877) 422-2823 and report this error code.", MB_OKCANCEL, MB_ICONEXCLAMATION, MB_DEFBUTTON1);
end
end