Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Perfect Disk and exceptions

Status
Not open for further replies.

QuarkIT

IS-IT--Management
Jan 11, 2005
34
US
Hey Mark or any of you other VB guru's.

I use a program called PerfectDisk on our network. I'm not a particular fan of the software, but it does help with performance slightly.

The software is client/server based, requiring that each client have several ports opened on their Windows firewall, and a few DLL's and an executable made exceptions as well.

The script they sent me originally required user interaction, and I wanted to remove as much of that as possible.

In the process I cut the script down so bare-bone that I am actually doing more harm then good.

Currently the script is this


Set WshShell = WScript.CreateObject("WScript.Shell")

pdpath = WshShell.RegRead("HKLM\Software\Microsoft\Windows\CurrentVersion\App Paths\PerfectDisk.exe\Path")

pdcommand = "netsh firewall add allowedprogram " & chr(34) & PDPath & "PDEngine.exe" & chr(34) & " PDEngine ENABLE SUBNET"
returncode = WshShell.Run(pdcommand,0,true)

pdcommand = "netsh firewall add allowedprogram " & chr(34) & PDPath & "PDSched.exe" & chr(34) & " PDScheduler ENABLE SUBNET"
returncode = WshShell.Run(pdcommand,0,true)

pdcommand = "netsh firewall add allowedprogram " & chr(34) & PDPath & "PDSchedPS.dll" & chr(34) & " PDSchedPS ENABLE SUBNET"
returncode = WshShell.Run(pdcommand,0,true)

pdcommand = "netsh firewall add allowedprogram " & chr(34) & PDPath & "PDEnginePS.dll" & chr(34) & " PDEnginePS ENABLE SUBNET"
returncode = WshShell.Run(pdcommand,0,true)

pdcommand = "netsh firewall add portopening TCP 135 RPC_PD ENABLE SUBNET"
returncode = WshShell.Run(pdcommand,0,true)
pdcommand = "netsh firewall add portopening TCP 445 DCOM_PD ENABLE SUBNET"
returncode = WshShell.Run(pdcommand,0,true)

What is happening is that this is a startup script, and if the application is not detected as being installed it will error out in the event log. I need to create an if then or some sort of check-sum to detect whether the application has installed properly or not before proceeding.
 
is your script the installation routine??

you are re-using returncode and therefore if all the first tasks fail but the last one succeeds you will think all is well.

you might consider something like

returncode = returncode + WshShell.Run(....

(or something similar using intTemp and returncode, or have a dictionary ojject containing all the returncodes then loop through??)

you also might consider some sort of sub (or function)...



Dim WshShell, pdpath, intReturn, intTemp

Set WshShell = WScript.CreateObject("WScript.Shell")
pdpath = WshShell.RegRead("HKLM\Software\Microsoft\Windows\CurrentVersion\App Paths\PerfectDisk.exe\Path")

intReturn = 0
Call doWork("PDScheduler ENABLE SUBNET", pdpath & "b.dll", intReturn, WshShell)
Call doWork("PDEnginePS ENABLE SUBNET", pdpath & "a.dll", intReturn, WshShell)



Sub doWork(ByVal strParams, ByVal strDll, ByRef intPassed, ByRef objShell)

Dim strTemp, returncode

strTemp = "netsh firewall add allowedprogram " & chr(34) & strDll & chr(34) & " " & strParams
returncode = objShell.Run(pdcommand,0,true)
intPassed = intPassed + returncode


End Sub


'you then might want to take it a step further and get your 'data', i.e. commands you want to run from an ini file?? then you write your script once and only have to update the ini file if you want to add more commands or change the order etc etc
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top