Link to home
Start Free TrialLog in
Avatar of TDKD
TDKDFlag for United States of America

asked on

I am in need of a vbs script or batch file that will...

I need a script that will check for the existance of the "BlackIce" firewall Service (or application location), and depending on whether or not it exists a different message box would greet the user, also if the "BlackIce" does not exist if the script could then invoke the "Office 2003" setup.exe.
ASKER CERTIFIED SOLUTION
Avatar of RobSampson
RobSampson
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Oh, and notice this bit:
WHERE Caption LIKE '%BlackIce%'

that may not be specific enough, if there's more than one service with BlackIce in it, so you can change that if required.

Rob.
Avatar of TDKD

ASKER

Hi RobSampson,

Thanks, I will try it tomorrow and get back to you.
No problem.
Avatar of TDKD

ASKER

Hi RobSampson,

I am going to give you the points, because you are brilliant!! But could you help me incorporate this batch file below, you see I have a script that will check for the "Blackd.exe" process and then runs this batch file below, as long as the "Blackd.exe" process is not running (ultimately I will remove this application if it exists). I like your script better because it actually searches for the existence of the "BlackIce Application", so I would rather use yours. The reason I want to use the batch file below is because it runs a few things the basic MSI package does not cover (e.g. I use the transform line in order to use the preconfigured O2K3 install and I install the EmailXtender add-on for Outlook. I also stop McAfee before installing, then I restart McAfee, then I run a shutdown command for XP and 2K clients.

The Script that runs first: ß But I like yours better J
Option Explicit
 
' Change these variables as required
dim strRequiredProcess: strRequiredProcess="Blackd.exe"
dim strBatchFile: strBatchFile="install\InstallOffice2003.bat"
 
if not QueryProcess(strRequiredProcess, ".") then
      ' Process is not running, so run batch file
      dim objShell: set objShell=CreateObject("WScript.Shell")
      objShell.Run """" & strBatchFile & """"
      set objShell=Nothing
end if
 
 
function QueryProcess(ByVal strProcess, strComputer)
      ' Returns true if service is running on given computer
      Dim objWMIService, objProcess, colProcess
      Dim strProc, blnFound
      
      blnFound=false
      strProcess=LCase(strProcess)
 
      Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
      Set colProcess = objWMIService.ExecQuery("Select * from Win32_Process")
 
      on error resume next
      For Each objProcess in colProcess
            strProc=lcase(objProcess.ExecutablePath)
            if Right(strProc, Len(strProcess))=strProcess then
                  wscript.echo "Contact the Help Desk before proceeding to the next step"
                  blnFound=true
                  exit for
            end if
      Next
      Err.Clear
      on error goto 0
      QueryProcess=blnFound

end function



The Batch file that runs if Blackd.exe is NOT running:

net stop "McAfee Framework Service"

net stop "Network Associates McShield"

net stop "Network Associates Task Manager"

xcopy "\\IP Address\Shared\Dantona\Office2003\install\psshutdown.exe" c:\


\\IP Address\Shared\Dantona\Office2003\install\setuppro.exe TRANSFORMS=Stratus.MST /qb-


\\IP Address\Shared\Dantona\Office2003\install\exclientsetup.exe /s /v"/qn INSTALLDIR=\"c:\Program Files\Legato\" ADDLOCAL=Sea,Common,Doc SEL_EXCHANGE=1 EX_EXSERVER=EXArchive"

net start "McAfee Framework Service"

net start "Network Associates McShield"

net start "Network Associates Task Manager"

;Windows XP Users--
shutdown.exe -r -t 30 -c "Office 2003 has finished upgrading and will now restart your PC!"

;Windows 2000 Users--
c:\psshutdown -r -m "Office 2003 has finished upgrading and will now restart your PC!"

exit
Avatar of TDKD

ASKER

Could you help me with this portion??
Hi, I am not able to test this, but instead of my "objShell.Run strCommand" line, I've replaced all that with a VBScript implementation of your batch file.....which I think should work.....

Regards,

Rob.
Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT Caption FROM Win32_Service WHERE Caption LIKE '%BlackIce%'", "WQL", _
                                       wbemFlagReturnImmediately + wbemFlagForwardOnly)
 
boolFound = False
For Each objItem In colItems
	boolFound = True
Next
 
If boolFound = True Then
	MsgBox "You have the BlackIce firewall installed.  Microsoft Office 2003 will not be installed."
Else
	MsgBox "Microsoft Office 2003 will now be installed."
	Set objShell = CreateObject("WScript.Shell")
	Set objFSO = CreateObject("Scripting.FileSystemObject")
	objShell.Run "net stop ""McAfee Framework Service""", 1, True
	objShell.Run "net stop ""Network Associates McShield""", 1, True
	objShell.Run "net stop ""Network Associates Task Manager""", 1, True
	objFSO.CopyFile "\\IP Address\Shared\Dantona\Office2003\install\psshutdown.exe", "C:\", True
	objShell.Run "\\IP Address\Shared\Dantona\Office2003\install\setuppro.exe TRANSFORMS=Stratus.MST /qb-", 1, True
	objShell.Run "\\IP Address\Shared\Dantona\Office2003\install\exclientsetup.exe /s /v""/qn INSTALLDIR=\""c:\Program Files\Legato\"" ADDLOCAL=Sea,Common,Doc SEL_EXCHANGE=1 EX_EXSERVER=EXArchive""", 1, True
	objShell.Run "net start ""McAfee Framework Service""", 1, True
	objShell.Run "net start ""Network Associates McShield""", 1, True
	objShell.Run "net start ""Network Associates Task Manager""", 1, True
	Set colItems = objWMIService.ExecQuery("SELECT Caption FROM Win32_OperatingSystem", "WQL", _
                                       wbemFlagReturnImmediately + wbemFlagForwardOnly)
	For Each objItem In colItems
		strCaption = objItem.Caption
	Next
	If InStr(strCaption, "XP") > 0 Then
		objShell.Run "shutdown.exe -r -t 30 -c ""Office 2003 has finished upgrading and will now restart your PC!"""
	Else
		objShell.Run "c:\psshutdown -r -m ""Office 2003 has finished upgrading and will now restart your PC!"""
	End If
End If

Open in new window

Avatar of TDKD

ASKER

Thanks very much Rob!! I will try it out, and thanks again for the follow up :-)
Avatar of TDKD

ASKER

If this works Rob, I will open another question and award you more points, as you already answered my first question...

I will inform you here as to the next question and how it will be named.
Thanks. Just post the link to the new question, and I will follow it up.

Glad to help.

Regards,

Rob.
Avatar of TDKD

ASKER

Hi RobSampson,

I didn't know how to get in touch with you on here?? So I figured I would add a message here...can you help me with this question of mine??

https://www.experts-exchange.com/questions/26316614/In-need-of-VBS-script-to-do-what-my-batch-file-does-an-additional-message-or-two.html?cid=1575&anchorAnswerId=33169812#a33169812