?
Solved

How to install local printer with IP from .bat or .vbs for users who are not admins?

Posted on 2005-03-14
14
Medium Priority
?
817 Views
Last Modified: 2008-01-09
I was wondering if someone could lend me hand? I need to set a logon script that installs a local printer to a TCP/IP port for a few users. The below works great if they are admins. Problem is, only one of the people in the group are. Is there a way to specify an admin account for the command? Or is there a better way using a vbs script? Thanks in advance.

rundll32 printui.dll,PrintUIEntry /if /b "Back Office Printer" /f %windir%\inf\ntprint.inf /r "IP_10.0.0.1" /m "HP LaserJet 8100 Series PS" /z /u
0
Comment
Question by:krugar77
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
  • +2
14 Comments
 
LVL 1

Expert Comment

by:cohortq
ID: 13538359
here buddy:

'******START OF SCRIPT********
Set WshNetwork = CreateObject("WScript.Network")
On Error Resume Next  'Ignores any errors

WshNetwork.AddWindowsPrinterConnection "\\10.0.0.1"
On Error Resume Next

WshNetwork.SetDefaultPrinter "\\10.0.0.1"
On Error Resume Next
'******END OF SCRIPT********

Copy this into notepad and rename the file into something like printer.vbs
This adds the printer to the computer, and then sets it as a default printer (if you want that) you don't have to you can just use it to connect the printer. Thing is that this needs to be run each time the user logs on. You cna set this in the user properties in active directory under login script. And you need to copy the vbs file in the scripts folder of the sysvol share on yer PDC. Plus, you need to have the printer dirvers installed on the server. I think it would be easier if you install this printer as a shared printer under the TCP/IP ports on yer server.
0
 
LVL 33

Expert Comment

by:NJComputerNetworks
ID: 13538367
I use Kixtart scripts for my Windows 200x domains.  Its very easy scripting language that is free.  It is meant for creating logon scripts.

www.kixtart.org - examples, and download software to load on your DC's.
www.kixscripts.com  - for script editor


If ADDPRINTERCONNECTION ("\\vleerbeer\hp laserjet 4") = 0
   ? "Added printer connection...."
Endif



-later
0
 

Author Comment

by:krugar77
ID: 13538666
Anyway to name them cohortq ?
0
Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

 

Author Comment

by:krugar77
ID: 13538697
That didn't work cohortq... oh well
0
 
LVL 1

Expert Comment

by:cohortq
ID: 13538791
Hmm are you trying to connect directly to the printer via a jet direct port? If so I would recommend creating a TCP/IP local printer port for that printer on yer server.  Its like Add Local printer, then select TCP/IP and like put in the ip of the printer I believe. You need to assign a share name to the printer on your server. Then you can do this.

'******START OF SCRIPT********
Set WshNetwork = CreateObject("WScript.Network")
On Error Resume Next  'Ignores any errors

WshNetwork.AddWindowsPrinterConnection "\\SERVERNAME\PRINTERSHARENAME"
On Error Resume Next

WshNetwork.SetDefaultPrinter"\\SERVERNAME\PRINTERSHARENAME"
On Error Resume Next
'******END OF SCRIPT********

so SERVERNAME = Name of your PDC server to host the printer
PRINTERSHARENAME = name you gave when you shared the printer on the server
0
 

Author Comment

by:krugar77
ID: 13538833
The other problem I have is that the majority of the people do not have local admin rights. How can I run the vbs script through group policy so that these users can install printers? Or is there a way from within the script to specify a user and password?
0
 
LVL 1

Accepted Solution

by:
cohortq earned 672 total points
ID: 13539072
you can run scripts from a goup policy.  From the group policy tool select your group policy then go to 'Windows Settings' -> 'Scripts (logon/logoff)' -> 'logon' -> then browse for your script.
0
 
LVL 1

Expert Comment

by:cohortq
ID: 13539129
From the group policy I believe yo ucan also enable the installation of printers as well. Hmm why dont you like just give them like administrative access, and then lock them down in the group policy. You can specify exactly what programs they can run, and you can restrict as much as you want. (also Im using the old group policy editor I know there is a new one that I hear is MUCH SIMPLER to use, and it is a free dl from microsoft)
0
 
LVL 3

Assisted Solution

by:arausch
arausch earned 664 total points
ID: 13540733
If you are trying to run this from a script, whether VB or a bat file, you can't exceed the permissions of the user running the script.  The simple solution to this is to add your users into the "Power Users" group.  They won't have full admin right, but they should be able to install a printer.
Another method is to use the RUNAS command when running your script, but this presents several security flaws (such as having the local admin password in a batch file or script).  Many people get around this problem by creating a batch file that does what you want and includes the admin password, and then converting it to a .com or .exe file using one of the free utils available:

http://www.computerhope.com/download/utility/bat2exe.com

http://www.subnetonline.com/cgi-bin/download/download2.pl?cat=none&name=bat2com

Hope that helps.

Thanks,
Andrew
0
 
LVL 35

Expert Comment

by:Nirmal Sharma
ID: 13543365
Group Policy idea is good :-)
0
 
LVL 35

Assisted Solution

by:Nirmal Sharma
Nirmal Sharma earned 664 total points
ID: 13543377
because Group Policy and its settings get applied under the security context of SYSTEM Account. Example is Microsoft Office, we apply or deploy this software using Software Installation snap-in in group policy. Clients restart their system and Microsoft Office is installed. In this same way login script works...and therefore all the settings defined works at the time before logs in and after user logs in.
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

NTFS file system has been developed by Microsoft that is widely used by Windows NT operating system and its advanced versions. It is the mostly used over FAT file system as it provides superior features like reliability, security, storage, efficienc…
New style of hardware planning for Microsoft Exchange server.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

752 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