Solved

Install network printers if in same ip range

Posted on 2008-10-01
6
336 Views
Last Modified: 2013-12-23
Hello,

we currently use a diferent batch files that installs about 20 printers on a users machine,depending on which floor they are on. we have to run this manually for each user. i would like to create a script / batch file to check what the ip address of the client is if matches criteria to call a certain batch file for the floor that the user is logged onto.

i hope this makes sense.
0
Comment
Question by:rgoddard2008
6 Comments
 

Expert Comment

by:gblund
ID: 22614096
Perhaps this could be in your interest. KixtArt is a tool which can help you set up scripts - here is the link for kixart http://www.kixtart.org/

With this tool i am sure you can make a script that checks for ip address and then connects them to the right printers. If you google for kixtart scripts you can easilly find examples on how to do this - if you connects printer based on groupmemberships instead.

Good luck
0
 
LVL 83

Expert Comment

by:oBdA
ID: 22614910
What are those "certain criterias"? Do you have different subnets per floor, or are they all in the same subnet, but different ranges?
0
 

Author Comment

by:rgoddard2008
ID: 22615120
same subnet different gateway and range of ip

example 192.168.1 = floor one
               192.168.2 = floor two
0
 
LVL 33

Accepted Solution

by:
MikeKane earned 250 total points
ID: 22615168
There was a question very similar to this that I Robsampson and I worked on :
http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_23749378.html?sfQueryTermInfo=1+case+select+strcsubnet

Use the same script and replace the Map Network Drive with a map printer statement instead and it would work for you as well.
0
 
LVL 83

Assisted Solution

by:oBdA
oBdA earned 250 total points
ID: 22615457
If you're using the standard network masks for a 192.168 private subnet (255.255.255.0), then your examples are on different subnets.
The script below will calculate the client's correct subnet based on the subnet mask, and you can then use the subnet to call the different batch scripts:
@echo off
setlocal
 
for /f "tokens=2 delims=:" %%a in ('ipconfig ^| find /i "IP Address"') do set IP=%%a
set IP=%IP: =%
for /f "tokens=2 delims=:" %%a in ('ipconfig ^| find /i "Subnet"') do set Mask=%%a
set Mask=%Mask: =%
for /f "tokens=1-4 delims=." %%a in ("%IP%") do (
  set s1=%%a
  set s2=%%b
  set s3=%%c
  set s4=%%d
)
for /f "tokens=1-4 delims=." %%a in ("%Mask%") do (
  set /a s1 "&=" %%a
  set /a s2 "&=" %%b
  set /a s3 "&=" %%c
  set /a s4 "&=" %%d
)
set LocalNet=%s1%.%s2%.%s3%.%s4%
echo Local Subnet: %LocalNet%
if "%LocalNet%"=="192.168.1.0" call Floor1.bat
if "%LocalNet%"=="192.168.2.0" call Floor2.bat

Open in new window

0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
An article on effective troubleshooting
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question