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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can someone help me to convert this .bat code into VBScript ?

Status
Not open for further replies.
Jan 14, 2022
1
PK
Can someone help me to convert this .bat code into VBScript ?
`````````````````````````````````````
:: Variables
set RULE_NAME=PDF
set PROGRAM=C:\Program Files\PDF\pdf.exe
netsh advfirewall firewall add rule name="%RULE_NAME%" dir=in action=block profile=any program="%PROGRAM%"
netsh advfirewall firewall add rule name="%RULE_NAME%" dir=out action=block profile=any program="%PROGRAM%"
`````````````````````````````````````
 
Just Google vbscript add firewall rule. That returned 187,000 results out there.
 
you can try something like this:
Code:
RULE_NAME="PDF"
PROGRAM="C:\Program Files\PDF\pdf.exe"

cmd1="netsh advfirewall firewall add rule name=""" & RULE_NAME & """ dir=in action=block profile=any program=""" & PROGRAM & """"
cmd2="netsh advfirewall firewall add rule name=""" & RULE_NAME & """ dir=out action=block profile=any program=""" & PROGRAM & """"

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

oShell.run "%comspec% /c " & cmd1
oShell.run "%comspec% /c " & cmd2

oShell = nothing
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top