Page 1 of 2 12>
Topic Options
#187932 - 2008-05-29 10:03 AM AddPrinterConnection in Windows 2003
REJ Offline
Fresh Scripter

Registered: 2008-05-29
Posts: 12
Hi All
We have just moved from windows 2000 to a windows 2003 Server
Everything work but my AddPrinterConnection in the script.

Does any one know how to fix this??

$Index=0
do
$Group=enumgroup($index)
if left($Group,7)="12345"
?$Group
$A=MapDrive($Group)
endif
$Index=$Index+1
until LEN ($Group)=0

IF InGroup("12345\ZAF.DOMAINUSERS")
SetDefaultPrinter ("\\PYE511\SHIP47")
ENDIF

FUNCTION MapDrive($Group)
SELECT
CASE $Group="12345\ZAF.DOMAINUSERS"
AddPrinterConnection ("\\PYE511\SHIP33")
AddPrinterConnection ("\\PYE511\SHIP37")
AddPrinterConnection ("\\PYE511\SHIP45")
SetDefaultPrinter ("\\PYE511\SHIP33")

ENDSELECT
ENDFUNCTION


This has work well for the last 4 years.

Thanks

Top
#187933 - 2008-05-29 10:16 AM Re: AddPrinterConnection in Windows 2003 [Re: REJ]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
You could check @error and @serror after adding a printer. They will tell you what is going on with AddPrinterConnection and if that is actually the part that is failing.

Edited by Mart (2008-05-29 10:17 AM)
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#187935 - 2008-05-29 11:10 AM Re: AddPrinterConnection in Windows 2003 [Re: Mart]
REJ Offline
Fresh Scripter

Registered: 2008-05-29
Posts: 12
Ok
So all I need to do is....

AddPrinterConnection ("\\PYE511\SHIP33")@error
AddPrinterConnection ("\\PYE511\SHIP37")@error
AddPrinterConnection ("\\PYE511\SHIP45")@error

Is this correct sorry I have not needed to script for some time now.

Top
#187936 - 2008-05-29 11:29 AM Re: AddPrinterConnection in Windows 2003 [Re: REJ]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
You could do something like this.
It shows the error code and the error text. The sleep 2 is just there so you can actually see what is displayed on your screen.

 Code:
AddPrinterConnection ("\\PYE511\SHIP33")
?@ERROR
?@SERROR
Sleep 2

AddPrinterConnection ("\\PYE511\SHIP37") 
?@ERROR
?@SERROR
Sleep 2

AddPrinterConnection ("\\PYE511\SHIP45")
?@ERROR
?@SERROR
Sleep 2
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#187937 - 2008-05-29 11:43 AM Re: AddPrinterConnection in Windows 2003 [Re: Mart]
REJ Offline
Fresh Scripter

Registered: 2008-05-29
Posts: 12
Thanks for that

I got the following:
0
0
The operation completed successfully.0
0
The operation completed successfully.0
0
The operation completed successfully0


Correct me if I am wrong but this is ok?? !!

Top
#187938 - 2008-05-29 11:48 AM Re: AddPrinterConnection in Windows 2003 [Re: REJ]
REJ Offline
Fresh Scripter

Registered: 2008-05-29
Posts: 12
Sorry
The server was pionted to the backup server

the is the error I got

123
The filename, directory name, or Volume label syntax is incorrect. 123
123
The filename, directory name, or Volume label syntax is incorrect. 123
123
The filename, directory name, or Volume label syntax is incorrect. 123

Any ideas?

Sorry about that

Top
#187939 - 2008-05-29 11:49 AM Re: AddPrinterConnection in Windows 2003 [Re: REJ]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
Yep these values show that the AddPrinterConnection function executes as it should.

Something else must be going wrong. You might want to run the script in debug mode so it executes line by line and you can see on what lines it fails. You can run the script in debug mode like this.

 Code:
kix32.exe -d yourscript.kix
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#187940 - 2008-05-29 12:30 PM Re: AddPrinterConnection in Windows 2003 [Re: Mart]
REJ Offline
Fresh Scripter

Registered: 2008-05-29
Posts: 12
I get the same error
123
The filename, directory name, or Volume label syntax is incorrect. 123
123
The filename, directory name, or Volume label syntax is incorrect. 123
123
The filename, directory name, or Volume label syntax is incorrect. 123
123
The filename, directory name, or Volume label syntax is incorrect. 123


I have tried:

Debug on

If ADDPRINTERCONNECTION ("\\SHE500\SHIP47") = 0
? "Added printer connection...."
else
?@ERROR
?@SERROR
Endif


AddPrinterConnection ("\\SHE500\SHIP33")
?@ERROR
?@SERROR
Sleep 2

AddPrinterConnection ("\\SHE500\SHIP37")
?@ERROR
?@SERROR
Sleep 2

AddPrinterConnection ("\\SHE500\SHIP45")
?@ERROR
?@SERROR
Sleep 9

Top
#187941 - 2008-05-29 01:32 PM Re: AddPrinterConnection in Windows 2003 [Re: REJ]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
The same error? Could have sworn that in your previous it showed all 0's

If you browse to the server on your network do you see the printers? If so are these names the same as in your script?
AddPrinterConnection takes the share name and SetDefaultPrinter takes the printer name.

[edit]
I should read better. Did not see your second post with the 123 error codes.
[/edit]


Edited by Mart (2008-05-29 02:21 PM)
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#187942 - 2008-05-29 02:55 PM Re: AddPrinterConnection in Windows 2003 [Re: Mart]
REJ Offline
Fresh Scripter

Registered: 2008-05-29
Posts: 12
If I run the script with out debug on
I get a error 1801 in the return value if this helps

I have had a look at Win32 error codes and that does not refer to the error I am getting so I am a bit lost at the moment.

any ideas

the share name is the same so is the server the only thing that has changed is upgraded from win 2000 to 2003.

Top
#187944 - 2008-05-29 03:13 PM Re: AddPrinterConnection in Windows 2003 [Re: REJ]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
Commenting out almost all of the code, running it, verify all is ok, uncomment a small part run it again and see if all is still ok. Repeat this until you find to part that is causing problems is the way to go right now.

Your code looks ok. Commenting out parts of it will tell you in what part you can find the error. It seems like AddPrinterConnection is giving you trouble. The error text suggests that it cannot find the server or printer. Could this be a permissions issue?


Edited by Mart (2008-05-29 03:15 PM)
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#187946 - 2008-05-29 03:36 PM Re: AddPrinterConnection in Windows 2003 [Re: Mart]
REJ Offline
Fresh Scripter

Registered: 2008-05-29
Posts: 12
I will break it down in to smaller bits and try it.

I can connect to them if I browse to the server and r-click, connect that works fine but not as a script using addprinterconnection.

Top
#187953 - 2008-05-29 04:33 PM Re: AddPrinterConnection in Windows 2003 [Re: REJ]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Two more things to check.

1. Make sure that the printer name and the printer share name are exactly the same on the print server. It will save you a lot of pain.

2. Check the event logs on the client for errors occurring around the time of the failures.

Top
#187955 - 2008-05-29 05:43 PM Re: AddPrinterConnection in Windows 2003 [Re: Richard H.]
REJ Offline
Fresh Scripter

Registered: 2008-05-29
Posts: 12
1.I checked the Nameing and it is all correct.

2.this is the event log error.
Event ID: 20

Printer Driver Xerox WorkCentre Pro 55 PS for Windows NT x86 Version-3 was added or updated. Files:- PSCRIPT5.DLL, PS5UI.DLL, xw55pSd.ppd, PSCRIPT.HLP, PSCRIPT.NTF, xw55pSd.ini, xw55pSd.xpb, xwpuisd.dll, xwprensd.dll, xwprsd.dll, xxuisd.dll, xxpsrsd.dll, xxstrsd.dll, xxressd.dll, xxuiwpsd.dll, xxwmsd.dll, xwphlp4p.hlp, xw55pSd.cfg, xw55pSd.dyc, xw55p4q.chm, XSNMX.DLL, XBD32.DLL, XBASE.DLL, XBDSNMP.DLL, XV2P.DLL, XBDSTAT.EXE, XMODELS.DLL, XLndAlrt.dat, FFACT_LM.pdf, LPS_UGP.pdf, LPCL_UGP.pdf.

Top
#187956 - 2008-05-29 05:47 PM Re: AddPrinterConnection in Windows 2003 [Re: REJ]
REJ Offline
Fresh Scripter

Registered: 2008-05-29
Posts: 12
All I have in my script is the following?
I have tried Upper case and lower case and still no joy this does still not map any printer for me.

Debug On

If InGroup("INETPSA\ZAF.MIS")
AddPrinterConnection ("\\she500\SHIP33")
AddPrinterConnection ("\\she500\SHIP31")
AddPrinterConnection ("\\she500\SHIP45")
AddPrinterConnection ("\\SHE500\SHIP48")
AddPrinterConnection ("\\SHE500\SHIP39")
AddPrinterConnection ("\\SHE500\SHIP42")
AddPrinterConnection ("\\SHE500\SHIP43")
AddPrinterConnection ("\\SHE500\SHIP32")
AddPrinterConnection ("\\SHE500\SHIP40")
AddPrinterConnection ("\\SHE500\SHIP41")
AddPrinterConnection ("\\SHE500\SHIP44")
DelPrinterConnection ("\\SHE500\SHIP54")
AddPrinterConnection ("\\SHE500\SHIP49")
AddPrinterConnection ("\\SHE500\SHIP35")
AddPrinterConnection ("\\SHE500\SHIP36")
AddPrinterConnection ("\\SHE500\SHIP50")
AddPrinterConnection ("\\SHE500\SHIP51")
AddPrinterConnection ("\\SHE500\SHIP37")
AddPrinterConnection ("\\SHE500\SHIP46")
AddPrinterConnection ("\\SHE500\SHIP38")
AddPrinterConnection ("\\SHE500\SHIP34")
AddPrinterConnection ("\\SHE500\SHIP59")
SetDefaultPrinter ("\\SHE500\SHIP47")
EndIf

Top
#187959 - 2008-05-29 06:59 PM Re: AddPrinterConnection in Windows 2003 [Re: REJ]
Destinova Offline
Just in Town

Registered: 2008-05-15
Posts: 4
I am having the exact same issue and it's driving me nuts. The AddPrinterConnection line is giving me error 123. The share and printer name are identical (copied and pasted), and I can browse to the share and see the printer.
Top
#187973 - 2008-05-30 09:20 AM Re: AddPrinterConnection in Windows 2003 [Re: Destinova]
REJ Offline
Fresh Scripter

Registered: 2008-05-29
Posts: 12
That good in one way at lease I am n ot the onlt one with the problem.
Top
#187978 - 2008-05-30 11:10 AM Re: AddPrinterConnection in Windows 2003 [Re: REJ]
Björn Offline
Korg Regular
*****

Registered: 2005-12-07
Posts: 953
Loc: Stockholm, Sweden.
test this first..
 Code:

If InGroup("INETPSA\ZAF.MIS")
'in group' ?
EndIf


and, if it doesn't return that - you have something fishy with the group.

Then, start with removing one of the printers your trying to connect - then add it. do it with the 'mart-style' (with @ERROR / @SERROR).


Edited by Björn (2008-05-30 12:26 PM)
_________________________
as long as it works - why fix it?
If it doesn't work - kix-it!

Top
#187982 - 2008-05-30 03:10 PM Re: AddPrinterConnection in Windows 2003 [Re: Björn]
REJ Offline
Fresh Scripter

Registered: 2008-05-29
Posts: 12
I get a retuen of "in group"

so that is working is it not??

Top
#187983 - 2008-05-30 03:11 PM Re: AddPrinterConnection in Windows 2003 [Re: REJ]
REJ Offline
Fresh Scripter

Registered: 2008-05-29
Posts: 12
If I add the following:

If InGroup("INETPSA\ZAF.MIS")
'in group' ?
AddPrinterConnection ("\\she500\SHIP33")
AddPrinterConnection ("\\she500\SHIP31")
EndIf

I get
in group
123
123

What does 123 mean??

Top
Page 1 of 2 12>


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

Who's Online
0 registered and 1188 anonymous users online.
Newest Members
StuTheCoder, M_Moore, BeeEm, min_seow, Audio
17884 Registered Users

Generated in 0.044 seconds in which 0.014 seconds were spent on a total of 14 queries. Zlib compression enabled.

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