Startup Script – Execute on Network only

Home Forums Scripting Windows Script Host Startup Script – Execute on Network only

This topic contains 4 replies, has 2 voices, and was last updated by  Anonymous 1 year ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts

  • CaTBuS
    Member
    #167319

    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?


    Anonymous
    #372072

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


    CaTBuS
    Member
    #309113
    RicklesP;n515182 wrote:
    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.


    Anonymous
    #372073

    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 HKLMCurrentControlSetServicesTcpipParameters, value ‘DhcpDomain’ or ‘Domain’ and the data should be your domain name.


    CaTBuS
    Member
    #309114
    RicklesP;n515204 wrote:
    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 HKLMCurrentControlSetServicesTcpipParameters, 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

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.