Solved

Install network printers if in same ip range

Posted on 2008-10-01
6
335 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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

I have published numerous articles here at Experts Exchange that present programs/scripts written in a language called AutoHotkey. Each of those articles has a brief paragraph describing where to download the product and how to install it. I have al…
Resolve DNS query failed errors for Exchange
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

760 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now