Jump to content

Detect if in home network... ?


atw
 Share

Recommended Posts

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

Link to comment
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.

Link to comment
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

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...