Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Script required to determine Location of Laptops on login, then call another script.

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,61761
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Script required to determine Location of Laptops on login, then call another script.
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Script required to determine Location of Laptops on lo... - 6/23/2008 10:42:45 PM   
  pbukn1

 

Posts: 3
Score: 0
Joined: 6/23/2008
Status: offline
Hi Guys

I have been using an existing startup vb script for some time which determines what your station's host name is an checks against a list of stations within the same script and installs an appropriate printer.  A little messy I know, but it works.

However, the site in which this script was running has now aquired an additional building elsewhere, which has had it's infrastructure linked via broadband and so enables users to login to the main server, located at the original site.  The script still works fine for workstations, but I am having trouble creating a script for the the laptop users as they do not have a permanent location.

Both sites have a different I.P range, but on the same subnet and so enable direct access to each other's server's and workstations.
After searching about for a script to prompt the user for a lacation and having had any real success, it suddenly occured to me to attempt a script that will determine a stations location by it's DHCP generated I.P address, then move it into then call the correct vbscript specific to the location.

Anyone have any ideas on a small script that could perhaps check for 1 of 2 I.P ranges within the stations currently assigned I.P address and depending on which range it discovers, will then run the appropriate vb printer script for that site?

Thank you for your time reading this.

 
 
Post #: 1
 
 RE: Script required to determine Location of Laptops o... - 6/23/2008 11:57:42 PM   
  ebgreen


Posts: 5041
Score: 31
Joined: 7/12/2005
Status: online
You could certainly do that. Have you tried anything yet?

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to pbukn1)
 
 
Post #: 2
 
 RE: Script required to determine Location of Laptops o... - 6/24/2008 8:36:12 PM   
  pbukn1

 

Posts: 3
Score: 0
Joined: 6/23/2008
Status: offline
I haven't tried anything to that affect yet, but would like to asap.

All I require is a small script to the effect of:

if i.p "192.168.100.*  call "site1.vbs
if i.p "192.168.101.* call "site2.vbs

The closest thing I can come up with is

Option Explicit
Dim IP_Address : IP_Address = GetIP()
If IP_Address = "192.18.67.*" Then
Call ScriptStart("tenzingstaff.vbs")
If IP_Address = "192.18.147.*" Then
Call ScriptStart("whcstaff.vbs")
End If
GetIP = IP
End Function

With this particular script it prompts for a further 'If' Statement.
I wouldn't know where to begin as I am no scripter, despite understanding a little of what the code means and how to manipulate it to suite my needs.

Any help would be appriciated.

< Message edited by pbukn1 -- 6/24/2008 11:32:08 PM >

(in reply to ebgreen)
 
 
Post #: 3
 
 RE: Script required to determine Location of Laptops o... - 6/25/2008 12:16:12 AM   
  ebgreen


Posts: 5041
Score: 31
Joined: 7/12/2005
Status: online
Well just to be clear we are here to help you write a script, not to write one for you. I would start with figuring out how to get the machine's IP address. There are a couple of ways to do this. Searching here or at google should get you headed in the right direction.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to pbukn1)
 
 
Post #: 4
 
 RE: Script required to determine Location of Laptops o... - 11/5/2008 7:03:34 AM   
  AndrewParker

 

Posts: 22
Score: 0
Joined: 6/29/2005
From:
Status: offline
There you go, you can mod this:

Const constLeedsSubnet = "192.168.2."

Sub subLeedsSubnet (strExecPrefix)
Dim strComputer
Dim objWMIService
Dim colNICs
Dim objNIC
Dim colTCPIPs
Dim objTCPIP
Dim strIPAddress
Dim bLeedsSubnet
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colNICS = objWMIService.ExecQuery _
     ("Select * from Win32_NetworkAdapter")
For Each objNIC in colNICS
 strComputer = "."
 Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
 Set colTCPIPs = objWMIService.ExecQuery _
      ("Select * from Win32_NetworkAdapterConfiguration Where MACAddress = '" & objNIC.MACAddress & "'")
 For Each objTCPIP in colTCPIPs
  On Error Resume Next
     For Each strIPAddress in objTCPIP.IPAddress
          If Left(strIPAddress,10) = constLeedsSubnet Then
    bLeedsSubnet = True
   End If
      Next
 Next
Next
If bLeedsSubnet Then
 strExecPrefix = "\\neptune\packages$\"
Else
 strExecPrefix = "\\sun\packages$\"
End If
End Sub


(in reply to pbukn1)
 
 
Post #: 5
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Script required to determine Location of Laptops on login, then call another script. Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts