Solved

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

Posted on 2008-10-21
12
381 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
  • 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
 
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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: 22799318
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Hello again, all.  For those of you that have been following along, you'll know that this is my third article on this topic (though it is not Part III).  This article is sort of remedial, and probably the topic with which I should have started the s…
Introduction During my participation as a VBScript contributor at Experts Exchange, one of the most common questions I come across is this: "I have a script that runs against only one computer. How can I make it run against a list of computers in …
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

759 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now