Search code examples
vbscriptbatch-filewminetshwindows-firewall

VBS or BAT script for opening WMI ports in windows firewall


How can you most reliable open ports need by WMI in windows firewall ? In need this in form of a BAT or VBS script and it needs to work on win XP and all newer.

Thank you very much.

EDIT1: win XP insted of 2000.


Solution

  • .BAT

    You can use the netsh command to open a specified port in the firewall. to use the wmi you must run something like this.

    to allow remote administration

    netsh firewall set service RemoteAdmin enable
    

    and to open the WMI port

    netsh firewall add portopening protocol=tcp port=135 name=DCOM_WMIPort
    

    Additionally you can read this article Connecting WMI Through Windows Firewall.

    VbScript

    if you want to use vbScript to accomplish this task , try using the HNetCfg.FwMgrCOM object in this article Windows Firewall Scripting you can found a serie of samples to manage the firewall settings using this com object from VbScript.