#206978 - 2013-03-27 07:16 AM
Translate Trend Micro VBS Install Script
|
eyeontech
Fresh Scripter
Registered: 2013-03-18
Posts: 6
Loc: Australia
|
Hi all,
I need a lot of help translating a Trend Micro VBS Script into KIX32. I have tried the Group Policy route but I would like to keep the existing KIX environment and roll out the new AV Agents the KIX way.
Here is the code:
pathOfWFBSHInstaller="msiexec /qn /i \\SERVER\netlogon\Kix32\Apps\TrendMicro\Agent_Installer.msi"
strComputer = "."
strOutput = ""
serviceCount = 0
totalServiceCountToCheck = 3
' check if WFBS-SVR is installed by detecting service ntrtscan, tmlisten, svcGenericHost are exist or not
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_Service")
For Each objService in colItems
strOutput = strOutput & objService.name & vbCr & vbLf
If objService.name = "ntrtscan" Then
serviceCount = serviceCount + 1
' Wscript.Echo "Service " & objService.Caption & " is " & objService.Started
ElseIf objService.name = "tmlisten" Then
serviceCount = serviceCount + 1
' Wscript.Echo "Service " & objService.Caption & " is " & objService.Started
ElseIf objService.name = "svcGenericHost" Then
serviceCount = serviceCount + 1
' Wscript.Echo "Service " & objService.Caption & " is " & objService.Started
End If
Next
If serviceCount <> totalServiceCountToCheck Then
Dim WshShell
Set WshShell = CreateObject("WScript.Shell")
WshShell.Run pathOfWFBSHInstaller
End if
Any takers?
|
|
Top
|
|
|
|
#206980 - 2013-03-27 08:00 AM
Re: Translate Trend Micro VBS Install Script
[Re: eyeontech]
|
Arend_
MM club member
   
Registered: 2005-01-17
Posts: 1896
Loc: Hilversum, The Netherlands
|
Hi, and welcome to KORG!
Here's your code:
$pathOfWFBSHInstaller="msiexec /qn /i \\SERVER\netlogon\Kix32\Apps\TrendMicro\Agent_Installer.msi"
$strComputer = "."
$strOutput = ""
$serviceCount = 0
$totalServiceCountToCheck = 3
; check if WFBS-SVR is installed by detecting service ntrtscan, tmlisten, svcGenericHost are exist or not
$objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" + $strComputer + "\root\cimv2")
$colItems = $objWMIService.ExecQuery("Select * from Win32_Service")
For Each $objService in $colItems
$strOutput = $strOutput + $objService.name + @CRLF
Select
Case $objService.name = "ntrtscan"
$serviceCount = $serviceCount + 1
;? "Service " + $objService.Caption + " is " + $objService.Started
Case $objService.name = "tmlisten"
$serviceCount = $serviceCount + 1
;? "Service " + $objService.Caption + " is " + $objService.Started
Case $objService.name = "svcGenericHost"
$serviceCount = $serviceCount + 1
;? "Service " + $objService.Caption + " is " + $objService.Started
EndSelect
Next
If $serviceCount <> $totalServiceCountToCheck
Dim $WshShell
$WshShell = CreateObject("WScript.Shell")
$WshShell.Run($pathOfWFBSHInstaller)
EndIf
|
|
Top
|
|
|
|
#207046 - 2013-04-03 05:15 PM
Re: Translate Trend Micro VBS Install Script
[Re: Glenn Barnas]
|
ShaneEP
MM club member
   
Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
|
Glenn is absolutely correct in his assertion that installations during login is a bad idea. But since you are probably in a bind, I modified the code just a bit to make the copying and execution easier.
$WFBSHInstaller = "Agent_Installer.msi"
$pathOfWFBSHInstaller = "\\SERVER\netlogon\Kix32\Apps\TrendMicro"
$pathOfLocalWFBSHInstaller = "%USERPROFILE%\Kix32\Apps\TrendMicro"
$strComputer = "."
$strOutput = ""
$serviceCount = 0
$totalServiceCountToCheck = 3
; check if WFBS-SVR is installed by detecting service ntrtscan, tmlisten, svcGenericHost are exist or not
$objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" + $strComputer + "\root\cimv2")
$colItems = $objWMIService.ExecQuery("Select * from Win32_Service")
For Each $objService in $colItems
$strOutput = $strOutput + $objService.name + @CRLF
Select
Case $objService.name = "ntrtscan"
$serviceCount = $serviceCount + 1
;? "Service " + $objService.Caption + " is " + $objService.Started
Case $objService.name = "tmlisten"
$serviceCount = $serviceCount + 1
;? "Service " + $objService.Caption + " is " + $objService.Started
Case $objService.name = "svcGenericHost"
$serviceCount = $serviceCount + 1
;? "Service " + $objService.Caption + " is " + $objService.Started
EndSelect
Next
If $serviceCount <> $totalServiceCountToCheck
Copy $pathOfWFBSHInstaller+"\"+$WFBSHInstaller $pathOfLocalWFBSHInstaller
Shell "msiexec /qn /i "+$pathOfLocalWFBSHInstaller+"\"+$WFBSHInstaller
If @error
"the installer failed with error:" @error
get $
Endif
EndIf
|
|
Top
|
|
|
|
#207074 - 2013-04-08 01:08 PM
Re: Translate Trend Micro VBS Install Script
[Re: eyeontech]
|
Glenn Barnas
KiX Supporter
   
Registered: 2003-01-28
Posts: 4401
Loc: New Jersey
|
It's actually simple as 1, 2, 3...  1. copy the install media to a shared folder. Create a BAT file there that will start the installation in unattended mode. 2. Create a bat file on the remote computer that maps a drive to your install share and runs the installation bat file. 3. Create and execute a scheduled task on the remote computer that runs the above bat file
The bat file to install the application is up to you.. it is installed in the folder on the network share with the application setup files.
The bat file to map to the share and run the install file (RmtInst.bat) would be something like this:@Echo Off
Rem Map a drive - define your server and share
Net Use Y: \\server\install_share
y:
REM CD to the folder where the app is stored
CD \AppFolder
REM Run the install bat file you created in step 1
Call MySetup.BAT This must be copied to the workstation, possibly the C:\TEMP folder. DO NOT use %TEMP% as it is unique per user. THIS PART can be triggered by the login script - code to determine if the required app is missing or outdated can be run by the users even without admin access. They can also copy the local script to the C:\Temp folder.
At this point, I usually write a file to a share somewhere with the workstation name in it. A process running on that server finds the file, extracts the computer name, and performs the following script to run the installation with elevated rights:Break On
; load the tcLib UDF Library
Call 'C:\UDF_Library\tclib.kxf'
; NOTE: The name of the target computer has been extracted from the file or
; otherwise provided in the $Target variable!!
tcInit() ; init the library
; Define the APPlication to run, a CoMmenT, and enable the Delete When Done option
$RV = tcDefineTask(“APP=C:\Temp\RmtInst.bat CMT=Remote Installer DWD=1”)
; Define the user account and password to run the task with
$RV = tcDefineTask (“USR=username PWD=password”)
; Save the task to the remote computer using the AppInstall task name
$RV = tcSetEvent($Target, 'AppInstall')
; Run the task created above immediately
$RV = tcExecute($Target, 'AppInstall') So, in just a few lines, you can create a remote task and execute it with whatever credentials you wish. We have a product that employs this basic methodology, and installations can be triggered by the login script and executed within seconds.
Unless you specify credentials (clear text) to PSExec, you can't use network resources. Installing software via the SYSTEM account isn't a good idea either.
Glenn
_________________________
Actually I am a Rocket Scientist!
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 429 anonymous users online.
|
|
|