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.
This topic is 12 years and 4 weeks old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
oneorangetree
Posts: 5
Last visit: Wed Feb 29, 2012 9:01 am

Add Printer Script gives errors

Post by oneorangetree »

Set
User avatar
oneorangetree
Posts: 5
Last visit: Wed Feb 29, 2012 9:01 am

Add Printer Script gives errors

Post by oneorangetree »

Script: PathToScriptFile.vbsLine: 2Error: The environment is incorrectCode: 8007000ASource: (null)
User avatar
oneorangetree
Posts: 5
Last visit: Wed Feb 29, 2012 9:01 am

Add Printer Script gives errors

Post by oneorangetree »

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
Last visit: Wed Feb 29, 2012 9:01 am

Add Printer Script gives errors

Post by oneorangetree »

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
Last visit: Mon Oct 19, 2015 9:21 am

Add Printer Script gives errors

Post by jhicks »

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
Last visit: Mon Oct 19, 2015 9:21 am

Add Printer Script gives errors

Post by jhicks »

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.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Add Printer Script gives errors

Post by jvierra »

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
Last visit: Mon Oct 19, 2015 9:21 am

Add Printer Script gives errors

Post by jhicks »

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
Last visit: Wed Feb 29, 2012 9:01 am

Add Printer Script gives errors

Post by oneorangetree »

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

Does that matter?
This topic is 12 years and 4 weeks old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked