Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - determine if PC is on a certain network

Reply
 
Old 05-15-2009   #1 (permalink)
Tony Logan


 
 

determine if PC is on a certain network

Trying to write a script that performs some actions based on whether the PC
is connected to a particularly named network in our company, but I'm having
trouble with the first part.

The PC could be connected to one of several company networks--foo1, foo2,
foo3, forinstance--or the PC could be not connected (laptop users connected
to their home wireless network, for example).

Is there VBscript that can tell me whether the PC is currently connected to
foo1 or not?






My System SpecsSystem Spec
Old 05-15-2009   #2 (permalink)
Pegasus [MVP]


 
 

Re: determine if PC is on a certain network


"Tony Logan" <TonyLogan@xxxxxx> wrote in message
news:9CDB781F-69ED-4689-8763-DF90DD6051CF@xxxxxx
Quote:

> Trying to write a script that performs some actions based on whether the
> PC
> is connected to a particularly named network in our company, but I'm
> having
> trouble with the first part.
>
> The PC could be connected to one of several company networks--foo1, foo2,
> foo3, forinstance--or the PC could be not connected (laptop users
> connected
> to their home wireless network, for example).
>
> Is there VBscript that can tell me whether the PC is currently connected
> to
> foo1 or not?
How can you tell if your PCs are connected to foo1? By their IP subnet? By
their %LogonServer%? Are the PCs in fact in a domain network or in a
workgroup network?


My System SpecsSystem Spec
Old 05-15-2009   #3 (permalink)
Richard Mueller [MVP]


 
 

Re: determine if PC is on a certain network


"Pegasus [MVP]" <news@xxxxxx> wrote in message
news:%23BALaQZ1JHA.1644@xxxxxx
Quote:

>
> "Tony Logan" <TonyLogan@xxxxxx> wrote in message
> news:9CDB781F-69ED-4689-8763-DF90DD6051CF@xxxxxx
Quote:

>> Trying to write a script that performs some actions based on whether the
>> PC
>> is connected to a particularly named network in our company, but I'm
>> having
>> trouble with the first part.
>>
>> The PC could be connected to one of several company networks--foo1, foo2,
>> foo3, forinstance--or the PC could be not connected (laptop users
>> connected
>> to their home wireless network, for example).
>>
>> Is there VBscript that can tell me whether the PC is currently connected
>> to
>> foo1 or not?
>
> How can you tell if your PCs are connected to foo1? By their IP subnet? By
> their %LogonServer%? Are the PCs in fact in a domain network or in a
> workgroup network?
At a command prompt run the "Set" command to view environment variables. If
USERDOMAIN has the value you want you can use the wshNetwork object to
retrieve the value in a VBScript program. For example:

Set objNetwork = CreateObject("Wscript.Network")
strDomain = objNetwork.UserDomain

--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--


My System SpecsSystem Spec
Old 05-15-2009   #4 (permalink)
Al Dunbar


 
 

Re: determine if PC is on a certain network


"Richard Mueller [MVP]" <rlmueller-nospam@xxxxxx> wrote in
message news:edjzija1JHA.4416@xxxxxx
Quote:

>
> "Pegasus [MVP]" <news@xxxxxx> wrote in message
> news:%23BALaQZ1JHA.1644@xxxxxx
Quote:

>>
>> "Tony Logan" <TonyLogan@xxxxxx> wrote in message
>> news:9CDB781F-69ED-4689-8763-DF90DD6051CF@xxxxxx
Quote:

>>> Trying to write a script that performs some actions based on whether the
>>> PC
>>> is connected to a particularly named network in our company, but I'm
>>> having
>>> trouble with the first part.
>>>
>>> The PC could be connected to one of several company networks--foo1,
>>> foo2,
>>> foo3, forinstance--or the PC could be not connected (laptop users
>>> connected
>>> to their home wireless network, for example).
>>>
>>> Is there VBscript that can tell me whether the PC is currently connected
>>> to
>>> foo1 or not?
>>
>> How can you tell if your PCs are connected to foo1? By their IP subnet?
>> By their %LogonServer%? Are the PCs in fact in a domain network or in a
>> workgroup network?
>
> At a command prompt run the "Set" command to view environment variables.
> If USERDOMAIN has the value you want you can use the wshNetwork object to
> retrieve the value in a VBScript program. For example:
But wouldn't that give the domain that the user belonged to rather than the
one the workstation belonged to?

/Al


My System SpecsSystem Spec
Old 05-18-2009   #5 (permalink)
Tony Logan


 
 

Re: determine if PC is on a certain network

"Pegasus [MVP]" wrote:
Quote:

> How can you tell if your PCs are connected to foo1? By their IP subnet? By
> their %LogonServer%? Are the PCs in fact in a domain network or in a
> workgroup network?
All good questions, Pegasus, which eventually led me to a solution. From the
PC, I try to ping the domain server and set a boolean variable. If True, the
PC is connected to that domain, and if False, it's not. Appears to be working
so far in testing. Thanks for the help!

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
determine app is 32 or 64 bit PowerShell
Determine PST Format PowerShell
Determine the machine logon PowerShell
Determine Network DHCP allocated IP addresses Vista networking & sharing
API to determine if UAC is enabled? Vista security


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46