Solved

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

Posted on 2008-10-21
12
389 Views
Last Modified: 2010-07-09
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
Comment
Question by:TDKD
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 5
12 Comments
 
LVL 65

Accepted Solution

by:
RobSampson earned 500 total points
ID: 22771244
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
 
LVL 65

Expert Comment

by:RobSampson
ID: 22771258
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
 
LVL 8

Author Comment

by:TDKD
ID: 22772261
Hi RobSampson,

Thanks, I will try it tomorrow and get back to you.
0
[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

 
LVL 65

Expert Comment

by:RobSampson
ID: 22772781
No problem.
0
 
LVL 8

Author Comment

by:TDKD
ID: 22776639
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
 
LVL 8

Author Closing Comment

by:TDKD
ID: 31508310
Could you help me with this portion??
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 22782804
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
 
LVL 8

Author Comment

by:TDKD
ID: 22785676
Thanks very much Rob!! I will try it out, and thanks again for the follow up :-)
0
 
LVL 8

Author Comment

by:TDKD
ID: 22785756
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
 
LVL 65

Expert Comment

by:RobSampson
ID: 22791247
Thanks. Just post the link to the new question, and I will follow it up.

Glad to help.

Regards,

Rob.
0
 
LVL 8

Author Comment

by:TDKD
ID: 33174015
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

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!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

One of the frequent problems with the installations is when some file or registry entry is not removed from the system upon un-installation of the product. Clean removal is always highly desirable. One major reason for that is badly authored inst…
I have been scripting applications way too long and can never remember how to create an ISS file.  So I decided to write this article to act as my own knowledge base for future reference, and hope you will also benefit. An ISS file is a response …
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

615 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question