Announcement

Collapse
No announcement yet.

Startup Script - Execute on Network only

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Startup Script - Execute on Network only

    I've got a great startup script (vbs) that I only want to run when I'm connected to my corporate network. For instance, I want it to execute when I'm docked in my office but not when I'm booting up outside of the office. I've tried utilizing the "docking state" registry key but can't get it to work consistently plus different manufactures have different registry locations/values so this is not the best way I think. Also, are moving towards MS DirectAccess so I also think looking for a unc path is not the answer either.

    Any ideas friends?

  • #2
    How about looking at the state of the Netlogon service? If the device can't talk to your DCs, netlogon can't start (I think).
    *RicklesP*
    MSCA (2003/XP), Security+, CCNA

    ** Remember: credit where credit is due, and reputation points as appropriate **

    Comment


    • #3
      Originally posted by RicklesP View Post
      How about looking at the state of the Netlogon service? If the device can't talk to your DCs, netlogon can't start (I think).
      Unfortunately, the netlogon service runs automatically regardless of being connected to my domain or not.

      Comment


      • #4
        OK then, how about looking at the Network Location Awareness state (NetworkName) to see if the machine recognizes being on your domain (the name you see if you hover over your networking icon in the system tray? You should be able to find this at HKLM\CurrentControlSet\Services\Tcpip\Parameters, value 'DhcpDomain' or 'Domain' and the data should be your domain name.
        *RicklesP*
        MSCA (2003/XP), Security+, CCNA

        ** Remember: credit where credit is due, and reputation points as appropriate **

        Comment


        • #5
          Originally posted by RicklesP View Post
          OK then, how about looking at the Network Location Awareness state (NetworkName) to see if the machine recognizes being on your domain (the name you see if you hover over your networking icon in the system tray? You should be able to find this at HKLM\CurrentControlSet\Services\Tcpip\Parameters, value 'DhcpDomain' or 'Domain' and the data should be your domain name.
          Very good idea. I'll play with this today. Ultimately, that might be more simplified that what I came up with. And with scripting, simple is what it's all about!!

          Code:
          ON ERROR RESUME NEXT
          
          Set WSHShell = CreateObject("WScript.Shell")
          Set WSHProcess = WSHShell.Environment("Process")
          Set objDomain = getObject("LDAP://rootDse")
          DomainString = objDomain.Get("dnsHostName")
          Ping = WSHShell.Run("ping -n 1 " & DomainString, 0, True)
          
          If Ping = 0 Then
              WScript.Echo "Domain Found"
          ElseIf Ping = 1 Then
              WScript.Echo "Domain Not Found. Not on Network"
          End If

          Comment

          Working...
          X