From 3e037f3d4b29133030253595e6c96d4b4163e506 Mon Sep 17 00:00:00 2001 From: Mario Fetka Date: Wed, 16 Oct 2019 18:28:41 +0200 Subject: [PATCH] add BrowserKill to setup and delsub --- sample/All/CLIENT_DATA/browserkill.opsiinc | 53 ++++++++++++++++++++ sample/All/CLIENT_DATA/delsub32.opsiscript | 5 ++ sample/All/CLIENT_DATA/delsub3264.opsiscript | 5 ++ sample/All/CLIENT_DATA/delsub64.opsiscript | 4 ++ sample/All/CLIENT_DATA/setup32.opsiscript | 5 ++ sample/All/CLIENT_DATA/setup3264.opsiscript | 6 +++ sample/All/CLIENT_DATA/setup64.opsiscript | 5 ++ 7 files changed, 83 insertions(+) create mode 100644 sample/All/CLIENT_DATA/browserkill.opsiinc diff --git a/sample/All/CLIENT_DATA/browserkill.opsiinc b/sample/All/CLIENT_DATA/browserkill.opsiinc new file mode 100644 index 0000000..4f050f7 --- /dev/null +++ b/sample/All/CLIENT_DATA/browserkill.opsiinc @@ -0,0 +1,53 @@ +; Opsi Builder to automate the creation of Opsi packages for the Opsi System +; Copyright (C) 2012 Daniel Schwager +; Copyright (C) 2014 Mario Fetka +; +; This program is free software: you can redistribute it and/or modify +; it under the terms of the GNU Affero General Public License as +; published by the Free Software Foundation, either version 3 of the +; License, or (at your option) any later version. +; +; This program is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +; GNU Affero General Public License for more details. +; +; You should have received a copy of the GNU Affero General Public License +; along with this program. If not, see . + +[ExecWith_BrowserKill] +Option Explicit +KillBrowsers() + +Sub KillBrowsers() +'Declare variables + Dim i + Dim wmiSvc,WQL,Processes,Process + Dim arrBrowserProcesses(9) + +'Initialize variables + arrBrowserProcesses(0)="iexplore.exe" + arrBrowserProcesses(1)="chrome.exe" + arrBrowserProcesses(2)="firefox.exe" + arrBrowserProcesses(3)="safari.exe" + arrBrowserProcesses(4)="opera.exe" + arrBrowserProcesses(5)="vivaldi.exe" + arrBrowserProcesses(6)="iron.exe" + arrBrowserProcesses(7)="MicrosoftEdge.exe" + arrBrowserProcesses(8)="msedge.exe" + + Set wmiSvc = GetObject("winmgmts:\\.\root\cimv2") + For i = 0 To UBound(arrBrowserProcesses) + wql = "SELECT * FROM Win32_Process WHERE Name='" & arrBrowserProcesses(i) & "'" + Set processes = wmiSvc.ExecQuery(wql) + Do While processes.Count > 0 + For Each process In processes + process.Terminate + Next + WScript.Sleep 200 + Set processes = wmiSvc.ExecQuery(wql) + Loop + Next + +End Sub + diff --git a/sample/All/CLIENT_DATA/delsub32.opsiscript b/sample/All/CLIENT_DATA/delsub32.opsiscript index 93d4819..35faa49 100644 --- a/sample/All/CLIENT_DATA/delsub32.opsiscript +++ b/sample/All/CLIENT_DATA/delsub32.opsiscript @@ -3,6 +3,8 @@ ; and published under the Terms of the General Public License. ; credits: http://www.opsi.org/en/credits/ +include_append "browserkill.opsiinc" + Set $UninstallProgram$ = $InstallDir$ + "\" + $UninstallExecutable$ Set $IniFile$ = $InstallDir$ + "\opsi-" + $ProductId$ + ".ini" @@ -44,6 +46,9 @@ if not (GetRegistryStringValue32("[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows sub_check_exitcode endif +;comment "Kill Web Browser" +;ExecWith_BrowserKill %System%\cscript.exe //b //nologo + comment "Delete files" Files_uninstall /32Bit diff --git a/sample/All/CLIENT_DATA/delsub3264.opsiscript b/sample/All/CLIENT_DATA/delsub3264.opsiscript index 291fde3..604854a 100644 --- a/sample/All/CLIENT_DATA/delsub3264.opsiscript +++ b/sample/All/CLIENT_DATA/delsub3264.opsiscript @@ -3,6 +3,7 @@ ; and published under the Terms of the General Public License. ; credits: http://www.opsi.org/en/credits/ +include_append "browserkill.opsiinc" Set $UninstallProgram32$ = $InstallDir32$ + "\" + $UninstallExecutable32$ Set $IniFile32$ = $InstallDir32$ + "\opsi-" + $ProductId$ + ".ini" @@ -49,6 +50,8 @@ if (($INST_SystemType$ = "x86 System") and ($INST_architecture$ = "system specif sub_check_exitcode endif + ;comment "Kill Web Browser" + ;ExecWith_BrowserKill %System%\cscript.exe //b //nologo comment "Delete files" Files_uninstall_32 /32Bit comment "Cleanup registry" @@ -94,6 +97,8 @@ if ($INST_SystemType$ = "64 Bit System") and (($INST_architecture$ = "system spe sub_check_exitcode endif + ;comment "Kill Web Browser" + ;ExecWith_BrowserKill %System%\cscript.exe //b //nologo comment "Delete files" Files_uninstall_64 /64Bit comment "Cleanup registry" diff --git a/sample/All/CLIENT_DATA/delsub64.opsiscript b/sample/All/CLIENT_DATA/delsub64.opsiscript index 47abead..2775a51 100644 --- a/sample/All/CLIENT_DATA/delsub64.opsiscript +++ b/sample/All/CLIENT_DATA/delsub64.opsiscript @@ -3,6 +3,7 @@ ; and published under the Terms of the General Public License. ; credits: http://www.opsi.org/en/credits/ +include_append "browserkill.opsiinc" Set $UninstallProgram$ = $InstallDir$ + "\" + $UninstallExecutable$ Set $IniFile$ = $InstallDir$ + "\opsi-" + $ProductId$ + ".ini" @@ -45,6 +46,9 @@ if not (GetRegistryStringValue64("[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows sub_check_exitcode endif +;comment "Kill Web Browser" +;ExecWith_BrowserKill %System%\cscript.exe //b //nologo + comment "Delete files" Files_uninstall /64Bit diff --git a/sample/All/CLIENT_DATA/setup32.opsiscript b/sample/All/CLIENT_DATA/setup32.opsiscript index f620e1d..6e9f853 100644 --- a/sample/All/CLIENT_DATA/setup32.opsiscript +++ b/sample/All/CLIENT_DATA/setup32.opsiscript @@ -7,6 +7,8 @@ requiredWinstVersion >= "4.11.4.6" ScriptErrorMessages=off +include_append "browserkill.opsiinc" + DefVar $MsiIdOld$ DefVar $UninstallProgram$ DefVar $UninstallProgramOld$ @@ -84,6 +86,9 @@ else comment "Copy files" Files_install /32Bit + ;comment "Kill Web Browser" + ;ExecWith_BrowserKill %System%\cscript.exe //b //nologo + comment "Patch Registry" Registry_install /32Bit diff --git a/sample/All/CLIENT_DATA/setup3264.opsiscript b/sample/All/CLIENT_DATA/setup3264.opsiscript index bbbd96f..95f2f48 100644 --- a/sample/All/CLIENT_DATA/setup3264.opsiscript +++ b/sample/All/CLIENT_DATA/setup3264.opsiscript @@ -7,6 +7,8 @@ requiredWinstVersion >= "4.11.4.6" ScriptErrorMessages=off +include_append "browserkill.opsiinc" + DefVar $MsiIdOld32$ DefVar $UninstallProgram32$ DefVar $UninstallProgramOld32$ @@ -93,6 +95,8 @@ else ChangeDirectory "%SCRIPTPATH%" Winbatch_install_32 Sub_check_exitcode + ;comment "Kill Web Browser" + ;ExecWith_BrowserKill %System%\cscript.exe //b //nologo comment "Copy files" Files_install_32 /32Bit comment "Patch Registry" @@ -109,6 +113,8 @@ else ChangeDirectory "%SCRIPTPATH%" Winbatch_install_64 Sub_check_exitcode + ;comment "Kill Web Browser" + ;ExecWith_BrowserKill %System%\cscript.exe //b //nologo comment "Copy files" Files_install_64 /64Bit comment "Patch Registry" diff --git a/sample/All/CLIENT_DATA/setup64.opsiscript b/sample/All/CLIENT_DATA/setup64.opsiscript index 3fc4e10..f7ecb88 100644 --- a/sample/All/CLIENT_DATA/setup64.opsiscript +++ b/sample/All/CLIENT_DATA/setup64.opsiscript @@ -7,6 +7,8 @@ requiredWinstVersion >= "4.11.4.6" ScriptErrorMessages=off +include_append "browserkill.opsiinc" + DefVar $MsiIdOld$ DefVar $UninstallProgram$ DefVar $UninstallProgramOld$ @@ -81,6 +83,9 @@ else Winbatch_install Sub_check_exitcode + ;comment "Kill Web Browser" + ;ExecWith_BrowserKill %System%\cscript.exe //b //nologo + comment "Copy files" Files_install /64Bit