Tinribs Posted January 26, 2021 Posted January 26, 2021 Hi All, Windows 10 PC network. Printers are mapped using a script called by GPO. Everything works fine on most machines but for one machine today that has stopped. Whenever the script calls this line: WshNetwork.SetDefaultPrinter Printerpath It throws up "The Environment is Incorrect". Problem is this only happens when it tries to map the default printer. Our two follow me queues for colour and mono printing map fine. Another computer in the same office mapping to the same printer works fine. The user can print to the requested printer via her ID card and follow me but her computer will just not map that printer as the default so she can print directly to it. I googled and found two answers but both are behind the experts.exchange paywall - can't afford £178!! Any ideas?
Jcx500 Posted January 26, 2021 Posted January 26, 2021 Try deleting her profile off the local machine ?
Jawloms Posted January 26, 2021 Posted January 26, 2021 What does the line say which sets "Printerpath"?
Tinribs Posted January 26, 2021 Author Posted January 26, 2021 Thanks The entire subroutine is here: Sub SetPrinter(ByVal PrinterPath)DIM WshNetworkSet WshNetwork = CreateObject("WScript.Network")WshNetwork.AddWindowsPrinterConnection(PrinterPath)WshNetwork.SetDefaultPrinter PrinterpathResult = WshShell.Popup("Sucessfully mapped" & vbCrLf & PrinterPath, 2, "Printer Mapped", 0 + 64)end sub The only other place I can find PrinterPath mentioned in the entire script is in the top line of that routine (Sub etc) There are two scripts that are used, one is run manually if a user needs to remap a printer and the other runs on logon and is linked to computer name and what OU it is in. Both scripts are identical.
siuko Posted January 26, 2021 Posted January 26, 2021 Well the most obivous thing is - does it include the space as shown in your post? WshNetwork.SetDefa ultPrinter
Jawloms Posted January 26, 2021 Posted January 26, 2021 I don't know a great deal about scripting, but have done a little programming in the past. I can't see where "Printerpath" is defined. According to this site, you need something like; Set PrinterPath = "\\research\library1" somewhere in the script.
Tinribs Posted January 26, 2021 Author Posted January 26, 2021 Thanks all. Very strange this one. It seems the printer involved has had it's name changed so the error we were receiving was very deceptive. When running the logon script we get different error that points straightaway at an invalid device name. Both scripts are identical so not entirely sure why they would give different errors and refer to different lines of code... Also no idea how the printer name was changed... Anyhoo - sorted now and one for the memory cells....
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now