• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 394
  • Last Modified:

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.
0
TDKD
Asked:
TDKD
  • 7
  • 5
1 Solution
 
RobSampsonCommented:
Hi, try this code out.

Regards,

Rob.
Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * 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")
	strCommand = "msiexec -i \\server\share\software\Office2003\OfficeStd.msi -qb"
	objShell.Run strCommand, 1, True
End If

Open in new window

0
 
RobSampsonCommented:
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.
0
 
TDKDAuthor Commented:
Hi RobSampson,

Thanks, I will try it tomorrow and get back to you.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
RobSampsonCommented:
No problem.
0
 
TDKDAuthor Commented:
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
0
 
TDKDAuthor Commented:
Could you help me with this portion??
0
 
RobSampsonCommented:
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

0
 
TDKDAuthor Commented:
Thanks very much Rob!! I will try it out, and thanks again for the follow up :-)
0
 
TDKDAuthor Commented:
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.
0
 
RobSampsonCommented:
Thanks. Just post the link to the new question, and I will follow it up.

Glad to help.

Regards,

Rob.
0
 
TDKDAuthor Commented:
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??

http://www.experts-exchange.com/Programming/Automation/Q_26316614.html?cid=1575#a33169812
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 7
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now