Batch File Help

Status
Not open for further replies.

TheDancingFetus

Baseband Member
Messages
68
Location
Cleveland
I have currently written a batch file that automatically installs printers from our print server when a user logs on to the PC. Problem is, if the user doesn't have Admin rights, none of the printers install, they error out. I was wonding if there is a way to add my Admin login credintials to the Batch file so the printers install. The goal is to have anyone who logs into this local machine to have access to all the printers avalible, without manually installing it for each user (Which I am currently doing).

My batch file looks like this:

REM Add printer
echo Installing [PCHPSPCF01] on [vwoachss002]!
RunDll32.EXE printui.dll,PrintUIEntry /in /n \\vwoachss002\PCHPSPCF01

REM Add printer
echo Installing [PCHPSBWL01] on [vwoachss002]!
RunDll32.EXE printui.dll,PrintUIEntry /in /n \\vwoachss002\PCHPSBWL01

REM Add printer
echo Installing [PCHPSBWL02] on [vwoachss002]!
RunDll32.EXE printui.dll,PrintUIEntry /in /n \\vwoachss002\PCHPSBWL02

REM Add printer
echo Installing [PCHPSBWL03] on [vwoachss002]!
RunDll32.EXE printui.dll,PrintUIEntry /in /n \\vwoachss002\PCHPSBWL03

REM Add printer
echo Installing [PCHPSBWL04] on [vwoachss002]!
RunDll32.EXE printui.dll,PrintUIEntry /in /n \\vwoachss002\PCHPSBWL04

REM Add printer
echo Installing [PCHPSBWL05] on [vwoachss002]!
RunDll32.EXE printui.dll,PrintUIEntry /in /n \\vwoachss002\PCHPSBWL05

REM Add printer
echo Installing [PCHPSBWL06] on [vwoachss002]!
RunDll32.EXE printui.dll,PrintUIEntry /in /n \\vwoachss002\PCHPSBWL06

echo Your default printer is [PCHPSPCF01] on [vwoachss002]
REM Set Default Printer
RunDll32.EXE printui.dll,PrintUIEntry /y /n \\vwoachss002\PCHPSPCF01

Any help on this, or any alternative would be greatly appreciated.
 
Here is what I created and works well

Code:
' 
' Printers.vbs - Windows Logon Script.
Set objNetwork = CreateObject("WScript.Network") 
objNetwork.AddWindowsPrinterConnection "[URL="file://hebcom01/HEBHP1320-001"]\\hebcom01\HEBHP1320-001[/URL]"
Set objNetwork = CreateObject("WScript.Network") 
objNetwork.AddWindowsPrinterConnection "[URL="file://hebcom01/HEBHP2420-001"]\\hebcom01\HEBHP2420-001[/URL]"
Set objNetwork = CreateObject("WScript.Network") 
objNetwork.AddWindowsPrinterConnection "[URL="file://hebcom01/HEBHP4000-002"]\\hebcom01\HEBHP4000-002[/URL]"
Set objNetwork = CreateObject("WScript.Network") 
objNetwork.AddWindowsPrinterConnection "[URL="file://hebcom01/HEBHP4000-003"]\\hebcom01\HEBHP4000-003[/URL]"
Set objNetwork = CreateObject("WScript.Network") 
objNetwork.AddWindowsPrinterConnection "[URL="file://hebcom01/HEBHP4015-001"]\\hebcom01\HEBHP4015-001[/URL]"
Set objNetwork = CreateObject("WScript.Network") 
objNetwork.AddWindowsPrinterConnection "[URL="file://hebcom01/HEBHP4050-001"]\\hebcom01\HEBHP4050-001[/URL]"
Set objNetwork = CreateObject("WScript.Network") 
objNetwork.AddWindowsPrinterConnection "[URL="file://hebcom01/HEBHP4050-003"]\\hebcom01\HEBHP4050-003[/URL]"
Set objNetwork = CreateObject("WScript.Network") 
objNetwork.AddWindowsPrinterConnection "[URL="file://hebcom01/HEBHP4050-004"]\\hebcom01\HEBHP4050-004[/URL]"
Set objNetwork = CreateObject("WScript.Network") 
objNetwork.AddWindowsPrinterConnection "[URL="file://hebcom01/HEBHP4600-001"]\\hebcom01\HEBHP4600-001[/URL]"
Set objNetwork = CreateObject("WScript.Network") 
objNetwork.AddWindowsPrinterConnection "[URL="file://hebcom01/HEBHP8100-001"]\\hebcom01\HEBHP8100-001[/URL]"
Set objNetwork = CreateObject("WScript.Network") 
objNetwork.AddWindowsPrinterConnection "[URL="file://hebcom01/HEBHP8150-001"]\\hebcom01\HEBHP8150-001[/URL]"
Set objNetwork = CreateObject("WScript.Network") 
objNetwork.AddWindowsPrinterConnection "[URL="file://hebcom01/HEBOfficeXerox-001"]\\hebcom01\HEBOfficeXerox-001[/URL]"
Set objNetwork = CreateObject("WScript.Network") 
objNetwork.AddWindowsPrinterConnection "[URL="file://hebcom01/HEBXerox-002"]\\hebcom01\HEBXerox-002[/URL]"
msgbox ("Printer installation complete.  Don't Forget to set your default printer")
 
The higher ups in the IT department doesn't want to have printers mapped through users Active Directory accounts, so that's why I'm looking to use a batch file on the local machine that I could put in the "All Users/Startup" Folder. I was able to add the "runas" command in my batch file, but I'll have to be there to put in my password for every new user. Coping the Default user settings works in a way. All the printers will show up in Printers and Faxes when a new user logs in, but all the printers say "Access Dennied" and won't work unless I manually install them.

Osiris:
Wouldn't I have to manually setup the Login Script for every new user? I woud like to make this as Automated as possible.
 
Thanks for the responses. I finally convinced my superiors to let me set all this stuff up in the Active Directory OU. Problem solved! I appreciate all effort to everyone that responded.
 
i'm thinking you'd want to add

on error resume next

at the beginning. this would suppress any error messages from being presented to the user.
 
Status
Not open for further replies.
Back
Top Bottom