Re: Startup Script – Execute on Network only

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

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


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