Add Printer Script gives errors

Anything VBScript-related, including Windows Script Host, WMI, ADSI, and more.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Locked
User avatar
oneorangetree
Posts: 5
Joined: Tue Feb 21, 2012 2:41 am

Add Printer Script gives errors

Post by oneorangetree » Tue Feb 21, 2012 2:44 am

Set

User avatar
oneorangetree
Posts: 5
Joined: Tue Feb 21, 2012 2:41 am

Add Printer Script gives errors

Post by oneorangetree » Tue Feb 21, 2012 3:20 am

Script: PathToScriptFile.vbsLine: 2Error: The environment is incorrectCode: 8007000ASource: (null)

User avatar
oneorangetree
Posts: 5
Joined: Tue Feb 21, 2012 2:41 am

Add Printer Script gives errors

Post by oneorangetree » Tue Feb 21, 2012 3:38 am

It can't be a driver issue because I copied a few lines of code from a Larger script so I can understand it better and the larger script works. The printer drivers are on the server and the larger script works fine on my PC. My code doesn't work for some odd reason Here is the Larger Script below Err.ClearPrinterNumber

User avatar
oneorangetree
Posts: 5
Joined: Tue Feb 21, 2012 2:41 am

Add Printer Script gives errors

Post by oneorangetree » Tue Feb 21, 2012 3:47 am

I am trying with WScript. The printer names are exact but the error says Line 2 Which is objNetwork.AddWindowsPrinterConnection

User avatar
jhicks
Posts: 1789
Joined: Sun Jan 21, 2007 11:31 pm

Add Printer Script gives errors

Post by jhicks » Wed Feb 29, 2012 3:24 am

Does your script work on any other computer?
Are there any other printers mapped on this computer?
Do you have any other connections or drive mappings to the print server on this computer?
What OS are you running?

You say that if you run the larger script and pick the SAME printer it works? If so there is something in your smaller script we are missing. Have you posted the entire short version you are running?

User avatar
jhicks
Posts: 1789
Joined: Sun Jan 21, 2007 11:31 pm

Add Printer Script gives errors

Post by jhicks » Wed Feb 29, 2012 4:21 am

I'm still not getting a clear picture. First, is what you posted originally the *complete* short script?

If the larger script works, then there is something else in your short version. Are you executing the large script also with WScript? There's some piece of information we aren't seeing, either related to credentials, UAC or something else.

User avatar
jvierra
Posts: 13507
Joined: Tue May 22, 2007 9:57 am
Contact:

Add Printer Script gives errors

Post by jvierra » Wed Feb 29, 2012 5:51 am

Do not run it as a logon script - not startup script. They asre not the same.

YOu really need to use CSCRIPT.

Be sure the file encoding is ANSI and not Unicode. Open it in notepad and select save as an look at the encoding of the file in the box labeled 'Encoding'

Be sure you do not have garbage characters in the file which can happen if you have copied it from a web site.



User avatar
jhicks
Posts: 1789
Joined: Sun Jan 21, 2007 11:31 pm

Add Printer Script gives errors

Post by jhicks » Wed Feb 29, 2012 6:17 am

I think he wrote the script but it could still have been saved as unicode. I think there is something specific about the script he is running. I forgot about checking encoding.

User avatar
oneorangetree
Posts: 5
Joined: Tue Feb 21, 2012 2:41 am

Add Printer Script gives errors

Post by oneorangetree » Wed Feb 29, 2012 10:01 am

The small script is being generated by an application that I wrote. Its being saved as Windows ANSI

Does that matter?

Locked