Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Map Network Printer with a Machine Startup Script NOT a User Logon Scr

Status
Not open for further replies.
Oct 27, 2004
32
US
Hi guys, I could do with some help on this.

I need to be able to assign Network Printers at 'Machine Startup' and NOT at the 'User Logon' as the users move around and the machines don't.

I've setup geographical OU's for the PC and Departmental OU's for the Users.

The Scripts for the users work fine and follow them around no matter what PC they logon to :)

BUT the script to assign Printers to Machines does not work the way I expected. Here's the script I'm using, I'll explain what happens after you've cast your eyes through it....

Dim multiPrinter, UNCpath1, UNCpath2
UNCpath1 = "\\SERVER01\PRINTER1"
UNCpath2 = "\\SERVER01\PRINTER2"
Set multiPrinter = CreateObject("WScript.Network")
multiPrinter.AddWindowsPrinterConnection UNCpath1
multiPrinter.AddWindowsPrinterConnection UNCpath2
WScript.Echo "Your printer is mapped from : " & UNCpath1 _ & "and from : " & UNCpath2
WScript.Quit


The script runs before the user logs on, I know this because I get the echo message OK, butu when I log in the printers are not mapped?????

If I run the script manually after I've logged in then the printers ARE mapped????

I've had a look around the forum, and not found any definative answers, maybe something to do with permissions?

Any help would be most greatful.

Cheers

Jay
 
Hello HelpJayPlz,

[1] Do you have on error resume next directive there?
[2] I bet using wscript.network is about the same as net.exe may not be launched remotely (server-launched) or it is executed in the wrong context.
[3] Try instead replacing the whole block with this?
[tt] UNCpath1 = "\\SERVER01\PRINTER1"
UNCpath2 = "\\SERVER01\PRINTER2"
cmdline="rundll32 printui.dll,PrintUIEntry /q /ga /n "
createobject(wscript.shell).run cmdline & UNCPath1,,true
createobject(wscript.shell).run cmdline & UNCPath2,,true
[/tt]

regards - tsuji
 
Ok tried that, with this script;

Dim cmdline, UNCpath1, UNCpath2
cmdline="rundll32 printui.dll,PrintUIEntry /q /ga /n "
Set WshShell = WScript.CreateObject("WScript.Shell")
UNCpath1 = "\\SERVER01\Printer1"
UNCpath2 = "\\SERVER01\Printer2"
WshShell.Run cmdline & UNCPath1,,True
WshShell.Run cmdline & UNCPath2,,True
WScript.Echo "Mapped your printer(s)"
WScript.Quit

It works but it only maps one printer (the first one, Printer1)

Any thoughts?

Thanks

Jay
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top