Scripting Question

Need a script to turn off firewall and turn on file sharing and discovery?

12/30/2014 2394 views

I need a script to run to turn off the firewall and turn on file sharing and discovery?


Please help.

Answer Summary:
0 Comments   [ + ] Show comments


  • This content is currently hidden from public view.
    Reason: Removed by member request For more information, visit our FAQ's.

Community Chosen Answer

You didn't mention what operating system, but you should be able to run a batch file similar to this:

netsh firewall set opmode disable
netsh firewall set service type=fileandprint mode=enable profile=all
netsh advfirewall firewall set rule group=”network discovery” new enable=yes

Answered 12/30/2014 by: jknox
Red Belt

  • Thanks, can you should me how to create a Batch file. I have used VB scripts and new in creating batch files to run through online shell.
    • I would use an online kscript and select "run a batch file" under the On Success portion of the Task.

      I would also suggest to make sure the commands I posted work properly on a test machine before creating the kscript.
      • is there away to do this silently no pop up cmd screen

All Answers

Wouldn't this be better handled by Group Policy ?

Answered 12/30/2014 by: spartacus
Black Belt

  • It could, but our policy people are not in I would like to handle it on the PC level
This is pretty much unavoidable as you are calling command line utilities. The changes are likely to be recorded in the registry so if you capture the changes made by each script line then you can add them directly without running the utilities.
Answered 12/30/2014 by: EdT
Red Belt

script is working thank you
Answered 12/30/2014 by: Kdebiasse
8th Degree Black Belt


getting CMDs to run without the pop is a bit tricky.

I have a vbs that can call a CMD (or any other exe etc), but it always seems a bit wrong in my head, you might just aswell create a vbs that does it all, anyway....

here is the script, you need to change the objshell.run bit, to your target, the name of your CMD file, or any other exe.


on Error Resume Next
' Declare Constants and Variables

Set objShell = CreateObject ("WScript.Shell")

objShell.Run "Firewall.cmd",0 , True

' Clean up

set objShell = Nothing

Answered 01/01/2015 by: Badger
Red Belt

Don't be a Stranger!

Sign up today to participate, stay informed, earn points and establish a reputation for yourself!

Sign up! or login

View more:


This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ