Jump to content

Local Areaconnection Firewall


Recommended Posts

I am New to Autoit , I have written a script and made a GUI window that performs several function in windows XP that configures many settings. I want to bulletproof some of these, instead of using the unreliable method of for example:

Send {DOWN 3}

and then using the spacebar: Send {SPACE}

to check or uncheck. I can't get the ControlCommand function to work in these windows. The problem is, the way that I am doing it now if they are already unchecked, when I run the script it checks them again. so I have to run it again to uncheck them.

:) Is That to confusing?

I can't even get it to Select the string 'Local Area Connection' in this window.

Here is the simple script ( I know it's ugly but I am learning)

Send("#r")

Sleep(1000)

send("Firewall.cpl")

Send("{ENTER}")

WinWaitActive("Windows Firewall", "General")

Sleep(1000)

ControlSend("Windows Firewall", "", "SysTabControl321", "{RIGHT 2}")

sleep(2000)

Send("{SPACE}")

ControlClick("Windows Firewall", "OK", "Button10")

Sleep(2000)

WinClose("Control Panel", "FolderView")

[size="2"][u]Beer is living proof that God loves us and wants us to be happy.-- Ben Franklin[/u][/size]

Link to comment
Share on other sites

...I can't get the ControlCommand function to work in these windows...

That is because it is a weird control panel applet :-(

AutoItSetOption("SendKeyDelay", 1) ;(milliseconds)
AutoItSetOption("WinWaitDelay", 1) ;(milliseconds)
AutoItSetOption("TrayIconDebug", 1) ;0-off

Run("rundll32.exe shell32.dll,Control_RunDLL firewall.cpl")
WinWait("Windows Firewall", "General")
WinActivate("Windows Firewall", "General")
WinWaitActive("Windows Firewall", "General")

ControlCommand("Windows Firewall", "General", "SysTabControl321", "TabRight", "")
WinWait("Windows Firewall", "Programs and Services")
WinActivate("Windows Firewall", "Programs and Services")
WinWaitActive("Windows Firewall", "Programs and Services")

ControlCommand("Windows Firewall", "Programs and Services", "SysTabControl321", "TabRight", "")
WinWait("Windows Firewall", "Default Settings")
WinActivate("Windows Firewall", "Default Settings")
WinWaitActive("Windows Firewall", "Default Settings")

Send("Local Area Connection")
Send("{SPACE}")
Send("{+}") would not work along with many other things.

Maybe others know how to do this via netsh?

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

That is because it is a weird control panel applet :-(

AutoItSetOption("SendKeyDelay", 1);(milliseconds)
AutoItSetOption("WinWaitDelay", 1);(milliseconds)
AutoItSetOption("TrayIconDebug", 1);0-off

Run("rundll32.exe shell32.dll,Control_RunDLL firewall.cpl")
WinWait("Windows Firewall", "General")
WinActivate("Windows Firewall", "General")
WinWaitActive("Windows Firewall", "General")

ControlCommand("Windows Firewall", "General", "SysTabControl321", "TabRight", "")
WinWait("Windows Firewall", "Programs and Services")
WinActivate("Windows Firewall", "Programs and Services")
WinWaitActive("Windows Firewall", "Programs and Services")

ControlCommand("Windows Firewall", "Programs and Services", "SysTabControl321", "TabRight", "")
WinWait("Windows Firewall", "Default Settings")
WinActivate("Windows Firewall", "Default Settings")
WinWaitActive("Windows Firewall", "Default Settings")

Send("Local Area Connection")
Send("{SPACE}")
Send("{+}") would not work along with many other things.

Maybe others know how to do this via netsh?

I also thought of the Send("Local Area Connection") , but if there are more than one

Local Area Connections (1)

Local Area Connections (2) .......

Say like on a laptop with wireless (I want to the leave the wireless firewall on)

would it uncheck (or check) the wrong box?

I will have to look at that Monday when I get back to work.

thank you for your reply and code Post.

[size="2"][u]Beer is living proof that God loves us and wants us to be happy.-- Ben Franklin[/u][/size]

Link to comment
Share on other sites

Send("Local") gets you to the first connection that starts with the name Local

Send("Local Area Connection") get you to the one with that exact name

...but it toggles the fake* "check box" with each space between the words.

If you use Send("Local Area Connection 2") you will toggle the fake* "check box" for "Local Area Connection" 3 times and then select "Local Area Connection 2".

* I say fake because the help file mentions this about Send("{+}")

"Usually checks a checkbox (if it's a "real" checkbox.)"

A wireless connection should have wireless in its connection name.

There has got to be a better way to script this.

Edited by herewasplato

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

Send("Local") gets you to the first connection that starts with the name Local

Send("Local Area Connection") get you to the one with that exact name

...but it toggles the fake* "check box" with each space between the words.

If you use Send("Local Area Connection 2") you will toggle the fake* "check box" for "Local Area Connection" 3 times and then select "Local Area Connection 2".

* I say fake because the help file mentions this about Send("{+}")

"Usually checks a checkbox (if it's a "real" checkbox.)"

A wireless connection should have wireless in its connection name.

There has got to be a better way to script this.

What if you sent it Raw like this: Send("LocalAreaConnection", 1)

would that fix the spacebar toggle on and off ? I only have one Local connection here on my home computer so I can't really test it.

By the way I like the way you wrote that script , you showed me alot of things I can do differently in all my scripts,

I Saw this : "AutoItSetOption("TrayIconDebug", 1) ;0-off " in your script and I looked up what it does in the help files but I don't see where it display the line.

Thanks!

Edited by Dalex

[size="2"][u]Beer is living proof that God loves us and wants us to be happy.-- Ben Franklin[/u][/size]

Link to comment
Share on other sites

What if you sent it Raw like this: Send("LocalAreaConnection", 1)

would that fix the spacebar toggle on and off ?...

Nope. Space is not affected by the Raw option and sending "LocalAreaConnection" will select a connection named "Local Area Connection"... but only because of the word Local. Sending "LocalAreaConnection2" will not select a connection named "Local Area Connection 2". [i'm not sure what you are planning on doing with this script, but if you are going to be the only one using it and if you are the only one using the computer that the script will run on... then just rename the connections to not contain a space.]

...By the way I like the way you wrote that script , you showed me alot of things I can do differently in all my scripts...

Thanks, but most my code just comes from others in the forum... just passing it along.

...I Saw this : "AutoItSetOption("TrayIconDebug", 1) ;0-off " in your script and I looked up what it does in the help files but I don't see where it display the line.

Run a test script with just these lines:
AutoItSetOption("TrayIconDebug", 1) ;0-off
Run("rundll32.exe shell32.dll,Control_RunDLL firewall.cpl")
WinWait("Windows Fireeeeeeeeewall", "General")
then hoover your mouse over the AutoIt icon in the system tray (down by the clock). It should show you the line number and the line of code (or part of the line) that the script is on. Click on that icon to exit the script.

BTW, the WinWait/WinActivate/WinWaitActive line might be an overkill for some scripts, but I've had other apps (like IM) pop-up at the worst possible time. With the WinWaitDelay set to 1 millisecond, it really doesn't add much to the execution time.

I sure wish someone would jump in and say if netsh could do this without windows.

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

BTW, the WinWait/WinActivate/WinWaitActive line might be an overkill for some scripts, but I've had other apps (like IM) pop-up at the worst possible time. With the WinWaitDelay set to 1 millisecond, it really doesn't add much to the execution time.

I sure wish someone would jump in and say if netsh could do this without windows.

I Like it because it makes more bulletproof!

I configure alot of computer at work, sometimes I will have 6 new computers lined up on the bench and we like to configure windows a certain way on them. I have scripted all of the "Windows XP" settings that we change and put them on a disk with and made a GUI window with checkboxes and an execute button.

it works well except for a few scripts that work like this firewall aplet.

No big deal I will just put a sleep statement in there so we can see if we have toggled the checks on or off.

Thank you Herewasplato, you have at least shon me that it wasn't me doing something wrong.

[size="2"][u]Beer is living proof that God loves us and wants us to be happy.-- Ben Franklin[/u][/size]

Link to comment
Share on other sites

...I configure alot of computer at work...

then you really should spend some time looking at netsh. Bring up a cmd window and enter "netsh firewall help" (without the quotes). I know that you can add/remove apps to the exceptions list. I just don't know if it can add/remove protection for connections. With netsh (comes with XP) you might be able to do all this with no windows popping up.

Anyone else out know this about netsh?

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

then you really should spend some time looking at netsh. Bring up a cmd window and enter "netsh firewall help" (without the quotes). I know that you can add/remove apps to the exceptions list. I just don't know if it can add/remove protection for connections. With netsh (comes with XP) you might be able to do all this with no windows popping up.

Anyone else out know this about netsh?

Cool I will check that out.

[size="2"][u]Beer is living proof that God loves us and wants us to be happy.-- Ben Franklin[/u][/size]

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...