Jump to content

Finding a PC on a domain


logonui
 Share

Recommended Posts

I work as an it Technician at a school and teachers have got notebooks that they can take home.

I am trying to write a program that will run on the notebook looking for a server on the network.

if it cannot find it the firewall will turn on. When the computer is found again then the firewall will be turned off so that we can access it for maintenence.

I am a newbie when it comes to autoit and I really don't know where to start.

Any help would be greatly appreciated

Cheers

Lee

Edited by logonui
Link to comment
Share on other sites

Try to ping the server, if not found then switch the firewall on.

User the Ping command try to find the registry entry that toggles the firewall and alter that.

Do you have any idea what the reg edit would be because I have goggled it and cant find anything

Link to comment
Share on other sites

Do you have any idea what the reg edit would be because I have goggled it and cant find anything

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\DomainProfile]

"EnableFirewall"=dword:00000000

"DisableNotifications"=dword:00000000

"DoNotAllowExceptions"=dword:00000000

here an example:

HotKeySet("{f4}", "_firewallon")
HotKeySet("{f3}", "_firewalloff")

while 1
    sleep(100)
WEnd

func _firewallon()
RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\DomainProfile", "EnableFirewall", "REG_DWORD", "1")
EndFunc

func _firewalloff()
RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\DomainProfile", "EnableFirewall", "REG_DWORD", "0")
EndFunc

good luck :P

Link to comment
Share on other sites

Try this.

$server = "server"
If RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SharedAccess", "Start") = 3 Then
    $objFirewall = ObjCreate("HNetCfg.FwMgr")
    $objPolicy = $objFirewall.LocalPolicy.CurrentProfile
    Ping($server, 250)
    If @error Then
        $objPolicy.FirewallEnabled = True
    Else
        $objPolicy.FirewallEnabled = False
    EndIf
Else
    MsgBox(0,"","Windows Firewall/Internet Connection Sharing (ICS) service is not running")
EndIf
Link to comment
Share on other sites

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\DomainProfile]

"EnableFirewall"=dword:00000000

"DisableNotifications"=dword:00000000

"DoNotAllowExceptions"=dword:00000000

here an example:

HotKeySet("{f4}", "_firewallon")
HotKeySet("{f3}", "_firewalloff")

while 1
    sleep(100)
WEnd

func _firewallon()
RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\DomainProfile", "EnableFirewall", "REG_DWORD", "1")
EndFunc

func _firewalloff()
RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\DomainProfile", "EnableFirewall", "REG_DWORD", "0")
EndFunc

good luck :P

Cheers for your help.

However I now have a new problem

This is where I am so far

#include <GUIConstants.au3>
;#NoTrayIcon


$S1 =   Ping("10.0.0.1")
$S2 =   Ping("10.0.0.2")
$S3 =   Ping("10.0.0.3")
$S4 =   Ping("10.0.0.4")
$S5 =   Ping("10.0.0.5")
$S6 =   Ping("10.0.0.6")


Do
;sleep(30000)
    
    If $S1 = 1 Then
        RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\DomainProfile", "EnableFirewall", "REG_DWORD", "0")
    ElseIf $S2 = 1 Then
        RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\DomainProfile", "EnableFirewall", "REG_DWORD", "0")
    ElseIf $S3 = 1 Then
        RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\DomainProfile", "EnableFirewall", "REG_DWORD", "0")
    ElseIf $S4 = 1 Then
        RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\DomainProfile", "EnableFirewall", "REG_DWORD", "0")
    ElseIf $S5 = 1 Then
        RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\DomainProfile", "EnableFirewall", "REG_DWORD", "0")
    ElseIf $S6 = 1 Then
        RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\DomainProfile", "EnableFirewall", "REG_DWORD", "0")
    Else
        RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\DomainProfile", "EnableFirewall", "REG_DWORD", "1")
    EndIf
Until ?????????????

I want to be able to make the script rerun every half an hour so that when they are on the internet at home it is not long before the firewall kicks in how can i change the script so that it does not stop until the user logs off or shuts down?

Sorry to be a pain and this is probably really obvious. :">

Link to comment
Share on other sites

You could make sure the script exe is in the startup folder then make it check every 30 minutes

#include <GUIConstants.au3>

while 1

$SS = 0
for $n = 1 to 6
   if  Ping("10.0.0." & $n) Then
     $SS = 1
     ExitLoop
   endif
     
 Next

RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\DomainProfile", "EnableFirewall", "REG_DWORD", Format("%d",$ss))


sleep(1000*60*30);30 minutes

WEnd
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

You could make sure the script exe is in the startup folder then make it check every 30 minutes

#include <GUIConstants.au3>

while 1

$SS = 0
for $n = 1 to 6
   if  Ping("10.0.0." & $n) Then
     $SS = 1
     ExitLoop
   endif
     
 Next

RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\DomainProfile", "EnableFirewall", "REG_DWORD", Format("%d",$ss))
sleep(1000*60*30);30 minutes

WEnd

Cheers for that. it seems to be OK but the registry key does not seem to want to work even if i open reg edit and do it manually the firewall does not activate or deactivate.

I'm Gonna have a look around the net again and see if I can find another way of changing the registry.

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...