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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Assistance troubleshooting adding Network Printers via VBS Script 1

Status
Not open for further replies.

Bullnuts

MIS
Aug 28, 2002
30
CA
I'm new to using the WshController Object which allows you to create a "controller script' that can run 'worker scripts' against remote computers. I'm in a W2k3 domain and run a xp pro desktop. I would like to essentailly create a vb controller script that reads off a text file of workstations and executes the worker script remotely on the text file and adds a network printer using AddWindowsPrinterConnection.exe

Controller Script would look something like this please excuse the format as I am not a scripter;
<
Code:
>
(Controller.vbs)
On Error Resume Next
Const ForReading = 1

Set objFSO = CreateObject("Scripting.FileSystemObject")

Set objTextFile = objFSO.OpenTextFile

("c:\scripts\wrkstns.txt", ForReading)

Do Until objTextFile.AtEndOfStream 
    strComputer = objTextFile.Readline

Dim oController, oRemoteScript

Set oController = WScript.CreateObject ("WSHController")
Set oRemoteScript = oController.CreateScript ("C:\scripts\addprinter.vbs", "text file here of workstation names.txt")

WScript.ConnectObject oRemoteScript, "remote_"
oRemoteScript.Execute

Do While oRemoteScript.Status = 0

   WScript.Sleep 100
Loop

MsgBox "remote execution completed with Status= " & oRemoteScript.Status

Loop

objTextFile.Close
 <
>
<
Code:
>
Worker script(Addprinter.vbs)

Set WshNetwork = WScript.CreateObject("WScript.Network")
PrinterPath = "\\servername\HPLJ_4100_3rd_Floor"
WshNetwork.AddWindowsPrinterConnection PrinterPath
WshNetwork.SetDefaultPrinter PrinterPath
 <
>
Thanks in Advance!
 
Why not just do it via a login script?
faq329-5798


I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
Mark,

Thanks for the response,

If I do it by login script, do I simply deploy it once and then remove it or does it have to stay in the login script?

My original thoughts on a login script would be that it would slow down client boot speeds, but if it was only for a couple of login's I could live with that.

My second issue is that I am only the LAN administrator of the Windows 2003 domain, THe WAN administrator is a novell guy and has the Novel Client setup for Login scripts. Its basically impossible for me to have him modify the novell login script and I have not tried using a windows login script on top of the novell, again I think it would delay me worse on bootup.

Are you aware if its possible to do what I originally requested? I know I'm very close, After fixing the XP SP2/3 issues of having to run wscript -regserver to fix my workstations, Tweaking the GPO to update the DCOM security access and then moding the workstations Registry; HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Script Host\Settings
enable Remote WSH -add a subkey entry named "Remote" of type REG_SZ To enable Remote WSH, set the value of Remote to 1;
I now know that I can get access to my workstations and have tried pushing examples ie Calc.exe/notepad.exe at the remote boxes and having the process running in the background, just need to figure out this printer stuff and all will be great!

I Already have the script made that reads off a PC list.txt and removes specified local printers. (very easy to find on the web)
My final step is getting the new Network printers added to the workstations using WSH.


best regards,
 
You could set it and forget it. Login delays will maybe be a fraction of a second.

Yes you can do it the way you are asking, however it requires you to do it with the PCs all turned on and that there be an active user session.

Using a login script you eliminate those downsides. Plus you gain the ability to modify the printers going forward by just tweaking the script.

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top