Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


RE: Install a printer based on range of IPs

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

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> RE: Install a printer based on range of IPs
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: <<   < prev  1 [2]
Login
Message << Older Topic   Newer Topic >>
 RE: Install a printer based on range of IPs - 5/14/2007 12:42:46 AM   
  Country73


Posts: 712
Score: 8
Joined: 8/25/2004
From: USA
Status: offline
I 'believe' what dm_4ever is trying to say is that you don't need to use the SELECT CASE in your script.
Inside of your 'IF / ELSEIF' block, you can add what you have in your SELECT CASE.

    If (intOct3 >= 1 And intOct3 <= 15) And (intOct4 >= 3 And intOct4 <= 30) Then
         IP = "x.x.1.a"
         'Location = "Location1"  '-This line is not needed, it is only for the SELECT CASE
         Printer = "-Location1"   '-This is the only thing you pull from the SELECT CASE, Set this up in the IF / ELSEIF
    ELSEIF...

(in reply to aburt)
 
 
Post #: 21
 
 RE: Install a printer based on range of IPs - 8/23/2007 4:21:34 AM   
  jpook

 

Posts: 30
Score: 0
Joined: 3/7/2007
Status: offline
Nice Code it worked great in one of my scripts.... On quick thing (Since I'm a rookie )

How to you keep the Dos box from popping up with the code below. I'm looping a script on over 2000+ workstaitons and having the Dos box pop up get in the way. =)~

------------------------------------------------ The code posted by dm_4ever -----------------------------
Function ResolveIP(computerName)
Dim objShell  :  Set objShell = CreateObject("WScript.Shell")
Dim objExec   :  Set objExec = objShell.Exec("ping " & computerName & " -n 1")
Dim RegEx     :  Set RegEx = New RegExp
RegEx.Pattern = "\[(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\]"
RegEx.IgnoreCase = True
RegEx.Global = True
ResolveIP = RegEx.Execute(objExec.StdOut.ReadAll)(0).Submatches(0)
End Function

(in reply to Country73)
 
 
Post #: 22
 
 RE: Install a printer based on range of IPs - 8/23/2007 4:43:34 AM   
  dm_4ever


Posts: 2414
Score: 38
Joined: 6/29/2006
From: Orange County, California
Status: offline
If you execute your script using cscript I believe the dox box is not visible.

_____________________________

dm_4ever

My philosophy: K.I.S.S - Keep It Simple Stupid
Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to jpook)
 
 
Post #: 23
 
 RE: Install a printer based on range of IPs - 8/29/2007 12:18:34 AM   
  jpook

 

Posts: 30
Score: 0
Joined: 3/7/2007
Status: offline
Thanks for the Help I ended up doing this to avoided the Dos Pop up box.


strComputer="xxxxxxxxx"
strIP=GetIP(strComputer)
Dim objNetwork : Set objNetwork = CreateObject("WScript.Network")
Dim localIP : localIP = strIP ' <span class="high"
Dim arrIPOct : arrIPOct = Split(localIP, ".")

If  ( arrIPOct(1) = X And arrIPOct(2) = Y ) Then
WScript.Echo "Skipped"
Else
WScript.Echo "Coping Now"
End If
Else
WScript.Echo "Can't Ping"
End If

Function GetIP(strComputer)
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colNicConfigs = objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")

For Each objNicConfig In colNicConfigs
For Each strIPAddress In objNicConfig.IPAddress
GetIP = strIPAddress
Next
Next
End Function

(in reply to dm_4ever)
 
 
Post #: 24
 
 
Page:  <<   < prev  1 [2]
 
  

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 >> RE: Install a printer based on range of IPs Page: <<   < prev  1 [2]
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