Sign in to follow this  
Followers 0
atw

Detect if in home network... ?

4 posts in this topic

Hi guys,

I bet this has been asked before, but I cannot figure out what to search for; so, sorry if I am repeating.

I want to set up a script to detect whether I am in my company network or not, and if I am, mount a network drive.

I am thinking that if the host PC's IP is 192.168.1.* and there is a share called sky_share on a machine called \\sbs2008 then, mount the drive.

How would I go about doing this?

Many thanks,

atw

Share this post


Link to post
Share on other sites



Look in the help file for Ping () and stringinstr ()

Ping the computer to see if its there and check the @IPAddress with stringinstr() to see if it has 192.168 in it.


Dating a girl is just like writing software. Everything's going to work just fine in the testing lab (dating), but as soon as you have contract with a customer (marriage), then your program (life) is going to be facing new situations you never expected. You'll be forced to patch the code (admit you're wrong) and then the code (wife) will just end up all bloated and unmaintainable in the end.

Share this post


Link to post
Share on other sites

Cool.

Here is my code (which works in the office):

$var = Ping("sbs2008",250)
If $var Then    ; also possible:  If @error = 0 Then ...
    DriveMapAdd ("I:", "\\sbs2008\IT RESOURCES")
    DriveMapAdd ("O:", "\\sbs2008\OFFICE ADMIN")
;    Msgbox(0,"Status","Online, roundtrip was: " & $var)
;Else
;    Msgbox(0,"Status","An error occured with number: " & @error)
EndIf

Is it possible to do:

If $var1 And $var2 Then

I cannot see it anywhere in the online docs?

Many thanks,

Andy

Share this post


Link to post
Share on other sites

Yes that syntax is legal. If both $var1 and $var2 are True/non-zero then execute whatever. Just be careful because the statement is True even if the value of the variables is -1 (which some functions return)

Share this post


Link to post
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
Sign in to follow this  
Followers 0