Hello,
Personnally I use this script :
If WScript.Arguments.Named.Exists("elevated") = False Then
CreateObject("Shell.Application").ShellExecute "wscript.exe", """" & WScript.ScriptFullName & """ /elevated", "", "runas", 1
WScript.Quit
End If
Dim WshShell
Set WshShell = CreateObject("WScript.Shell")
Dim OCS
' Uninstall agent ocs if is installed
' Verification on OS 32 Bits
On error resume next
OCS = WshShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\OCS Inventory Agent\UninstallString")
If err.number = 0 then
WshShell.Run "CMD.EXE /C net stop ""OCS INVENTORY SERVICE""",0,True
WshShell.Run "CMD.EXE /C """ & OCS & """ /S /NOSPLASH",0,True
WshShell.Run "CMD.EXE /C rmdir ""%ProgramFiles%\OCS Inventory Agent"" /S /Q",0,True
WshShell.Run "CMD.EXE /C rmdir ""%SystemDrive%\ocs-ng"" /S /Q",0,True
WshShell.Run "CMD.EXE /C rmdir ""%ProgramData%\OCS Inventory NG"" /S /Q",0,True
WshShell.Run "CMD.EXE /C sc delete ""OCS INVENTORY""",0,True
End If
' Verification on OS 64 Bits
On error resume next
OCS = WshShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\OCS Inventory Agent\UninstallString")
If err.number = 0 then
WshShell.Run "CMD.EXE /C net stop ""OCS INVENTORY SERVICE""",0,True
WshShell.Run "CMD.EXE /C """ & OCS & """ /S /NOSPLASH",0,True
WshShell.Run "CMD.EXE /C rmdir ""%ProgramFiles(x86)%\OCS Inventory Agent"" /S /Q",0,True
WshShell.Run "CMD.EXE /C rmdir ""%SystemDrive%\ocs-ng"" /S /Q",0,True
WshShell.Run "CMD.EXE /C rmdir ""%ProgramData%\OCS Inventory NG"" /S /Q",0,True
WshShell.Run "CMD.EXE /C sc delete ""OCS INVENTORY""",0,True
End If
' Verification Agent V2 on 32Bit
On error resume next
OCS = WshShell.RegRead("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\OCS Inventory NG Agent\UninstallString")
If err.number = 0 then
WshShell.Run "CMD.EXE /C net stop ""OCS INVENTORY SERVICE""",0,True
WshShell.Run "CMD.EXE /C taskkill /F /IM ocssystray.exe",0,True
WshShell.Run "CMD.EXE /C """ & OCS & """ /S /NOSPLASH",0,True
WshShell.Run "CMD.EXE /C rmdir ""%ProgramFiles%\OCS Inventory Agent"" /S /Q",0,True
WshShell.Run "CMD.EXE /C rmdir ""%SystemDrive%\ocs-ng"" /S /Q",0,True
WshShell.Run "CMD.EXE /C rmdir ""%ProgramData%\OCS Inventory NG"" /S /Q",0,True
WshShell.Run "CMD.EXE /C sc delete ""OCS INVENTORY""",0,True
End If
' Verification Agent V2 on 64Bit
On error resume next
OCS = WshShell.RegRead("HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\OCS Inventory NG Agent\UninstallString")
If err.number = 0 then
WshShell.Run "CMD.EXE /C net stop ""OCS INVENTORY SERVICE""",0,True
WshShell.Run "CMD.EXE /C taskkill /F /IM ocssystray.exe",0,True
WshShell.Run "CMD.EXE /C """ & OCS & """ /S /NOSPLASH",0,True
WshShell.Run "CMD.EXE /C rmdir ""%ProgramFiles%\OCS Inventory Agent"" /S /Q",0,True
WshShell.Run "CMD.EXE /C rmdir ""%SystemDrive%\ocs-ng"" /S /Q",0,True
WshShell.Run "CMD.EXE /C rmdir ""%ProgramData%\OCS Inventory NG"" /S /Q",0,True
WshShell.Run "CMD.EXE /C sc delete ""OCS INVENTORY""",0,True
End If
Err.Clear
On Error Goto 0