Solved

printer script hell on windows 7

Posted on 2010-08-13
9
3,708 Views
Last Modified: 2012-08-13
Hello,
Can someone please shed the light on this for me.
Below is my script that runs/ran perfect on Win XP, but on Windows 7 it will not.
If I run the script on the machine from the network (in a share), it runs just fine.
The driver accept prompt comes up and all is well.
But when I run the script from a GPO, no luck.
The GPO is set for loopback/merge.
The error that I receive is: Line 28, environment  is incorrect 8007000A

We are running windows 2003 R2 server.
We print via computer, not user.
If there is a better way to script this, I am all in favor.
This is a bit high priority, so whatever works...

Thanks a bunch.
Rem Script created: 28.08.2007 18:07
Rem Author: 

'Generic printer mapping for assinging printers to ou's
'The printers are all on PRINTSERVER
'Faculty Printers

Option Explicit
Dim objNetwork, str1stflrpr1, str2ndflrbw, stradmissbw, stradmisscol
Dim stradhead, strbaronrm, strclabpr1, strcollegepr1, strdeansoffice, strdevpr1
Dim strfacrmpr1, strlibmain, strrecepr1

str1stflrpr1 ="\\PRINTSERVER\1STFLRPR1"
str2ndflrbw ="\\PRINTSERVER\2NDFLRBW"
'stradmissbw ="\\PRINTSERVER\ADMISSBW"
stradmisscol="\\PRINTSERVER\ADMISSCOL"
'stradhead="\\PRINTSERVER\AHEAD"
strbaronrm ="\\PRINTSERVER\BARONRM"
strclabpr1="\\PRINTSERVER\CLABPR1"
'strcollegepr1="\\PRINTSERVER\COLLEGEPR1"
'strdeansoffice="\\PRINTSERVER\DEANSOFFICE"
'strdevpr1="\\PRINTSERVER\DEVPR1"
strfacrmpr1="\\PRINTSERVER\FACRMPR1"
strlibmain="\\PRINTSERVER\LIBMAIN"
'strrecepr1="\\PRINTSERVER\RECEPR1"
'Line 26
Set objNetwork = CreateObject("WScript.Network")
objNetwork.AddWindowsPrinterConnection str1stflrpr1
objNetwork.AddWindowsPrinterConnection str2ndflrbw
'objNetwork.AddWindowsPrinterConnection stradmissbw
'objNetwork.AddWindowsPrinterConnection stradmisscol

'objNetwork.AddWindowsPrinterConnection stradhead
objNetwork.AddWindowsPrinterConnection strbaronrm
objNetwork.AddWindowsPrinterConnection strclabpr1
'objNetwork.AddWindowsPrinterConnection strcollegepr1

'objNetwork.AddWindowsPrinterConnection strdeansoffice
'objNetwork.AddWindowsPrinterConnection strdevpr1
objNetwork.AddWindowsPrinterConnection strfacrmpr1

objNetwork.AddWindowsPrinterConnection strlibmain
'objNetwork.AddWindowsPrinterConnection strrecepr1

'WScript.Echo "Check the Printers Folder for : " & strUNCPrinter
objNetwork.SetDefaultPrinter strfacrmpr1

WScript.Quit

Open in new window

0
Comment
Question by:MARIANAPOLIS
[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
  • 4
9 Comments
 
LVL 1

Expert Comment

by:odd lie
ID: 33433142
Yuo might try to run windows 7 as XP and in that VirtualPC run the script and see if that works.

Oldelphi
0
 

Author Comment

by:MARIANAPOLIS
ID: 33433176
There is no virtualPC on the computer.  That would be a bit hard to do on all of our clients.
I may be understanding this answer incorrectly.

Thank-you
0
 
LVL 33

Expert Comment

by:digitap
ID: 33433840
Add this after your declared variables then test your script again.

Set WSHNetwork = WScript.CreateObject("WScript.Network")
0
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 
LVL 33

Expert Comment

by:digitap
ID: 33433843
never mind...i see that you have that already...
0
 

Author Comment

by:MARIANAPOLIS
ID: 33445386
I am still getting the same error.  I put the set objNetwork = CreateObject("Wscript.network") right below the declaration.

Does anyone suggest using a different script or a different method.
Is there an add-on that would fake 2003 into being a 2008 server to enable preferences?

Thank-you
0
 
LVL 33

Accepted Solution

by:
digitap earned 500 total points
ID: 33445482
Looking through your script again, I see that you don't have any error handling.  within your script, insert after Option Explicit

On Error Resume Next

It may not be all the printers that are causing trouble, it may only be the one.  However, since it's erroring on the first one and stopping the script, you'll never know.  Try it and let me know how it goes.
0
 

Author Closing Comment

by:MARIANAPOLIS
ID: 33445694
Thank-you to everyone
0
 

Author Comment

by:MARIANAPOLIS
ID: 33445707
The loopback seemed to be also giving me some issues.
Once putting the printer script strictly in the startup GPO, all was fine.
The error checking was also a valuable asset.

0
 
LVL 33

Expert Comment

by:digitap
ID: 33445743
glad we could help and thanks for providing feedback about what solved the issue.  thanks for the points!
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Always backup Domain, SYSVOL etc.using processes according to Microsoft Best Practices. This is meant as a disaster recovery process for small environments that did not implement backup processes and did not run a secondary domain controller that ne…
Active Directory security has been a hot topic of late, and for good reason. With 90% of the world’s organization using this system to manage access to all parts of their IT infrastructure, knowing how to protect against threats and keep vulnerabil…
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Suggested Courses

624 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