Page 1 of 1 1
Topic Options
#142772 - 2005-07-01 04:23 AM SetDefaultPrinter error code 2
Skip Offline
Fresh Scripter

Registered: 2005-07-01
Posts: 41
I am new to posting and to KIXtart. I appreciate any advice I can get with this problem. My workstations are all in groups, I am calling a udf file to determine which printers to map, which is working great. I can not get the SetDefaultPrinter function to work at all though.

Before posting I spent time looking over the site, but everything was verifying the code was correct.
Code:

Call '\\PHI2\NETLOGON\Computeringroup.udf'

; Product Types will have to be added for additional operating systems
If @PRODUCTTYPE = "Windows NT Workstation"
Or @PRODUCTTYPE = "Windows 2000 Professional"
Or @PRODUCTTYPE = "Windows XP Professional"

If ComputerInGroup('ph_prt_confroom_area')=1
If AddPrinterConnection ("\\phi2\copier2") = 0
? "Added printer connection...."
If SetDefaultPrinter ("\\phi2\copier2") = 0
? "Default printer was set to \\phi2\copier2...."
Else
? "Set Default Failed"
? "Error Code: " +@ERROR
EndIf
EndIf
EndIf


As you can see I put some if statements in there. When the code is run, the following is returned.
****
z:\kix32 mapprinters.kix
Added printer connection....
Default printer was set to \\phi2\copier2....
Set Default Failed
Error Code: 2
z:\
****

Thanks very much in advance for any assistance on this. I will be sure to follow up and let you know how things turn out.

Skip
_________________________
-sphilip

Top
#142773 - 2005-07-01 04:26 AM Re: SetDefaultPrinter error code 2
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Are the printer names the same as the share names?
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#142774 - 2005-07-01 04:29 AM Re: SetDefaultPrinter error code 2
Skip Offline
Fresh Scripter

Registered: 2005-07-01
Posts: 41
No, If I go to the properties on the printer the name that appears on the general tab is"SAVIN 2545/2245 RPCS"
_________________________
-sphilip

Top
#142775 - 2005-07-01 04:46 AM Re: SetDefaultPrinter error code 2
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
then fix it
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#142776 - 2005-07-01 04:49 AM Re: SetDefaultPrinter error code 2
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
to translate les' awesome knowledge:
setdefaultprinter() takes \\servername\PRINTERNAME and not sharename.
_________________________
!

download KiXnet

Top
#142777 - 2005-07-01 04:53 AM Re: SetDefaultPrinter error code 2
Skip Offline
Fresh Scripter

Registered: 2005-07-01
Posts: 41
My apologies, it has been a long day. The return I get if I run the script is as follows:
****
z:\kix32 mapprinters.kix
Added printer connection....
Default printer is: \\phi2\HP4600dn
Set Default Failed
Error Code: 2
z:\
****
\\phi2\HP4600dn is my current default printer.

If I look at the printer in my printers folder it's display name is "SAVIN 2545/2245 RPCS on phi2" But on the server, in the dialog box it is "SAVIN 2545/2245 RPCS" We are running AD and the printer is listed in the directory. It is installed on a 2003 Server, if that helps.

Again, thanks for your help.
_________________________
-sphilip

Top
#142778 - 2005-07-01 05:00 AM Re: SetDefaultPrinter error code 2
Skip Offline
Fresh Scripter

Registered: 2005-07-01
Posts: 41
That is awesome. Les, Lonkero, I sure hope you know how big of a smile I have on my face right now. Thank you both, so much.

Have a great day.
_________________________
-sphilip

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 1619 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.035 seconds in which 0.015 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org