Page 1 of 1 1
Topic Options
#139501 - 2005-05-10 04:51 PM AddPrinterConnection fails with error code 2
homar76 Offline
Fresh Scripter

Registered: 2005-05-10
Posts: 8
Loc: AUSTRIA
Hello,
when trying to map a remote printer to a server via AddPrinterConnection, the error code 2 is returned (FILE_NOT_FOUND). I already tried different printers, its always the same error code.

Are there any suggestions whatīs going wrong? Is it possible that some user permissions are to restrictive? Is the assumption correct, that the error "file not found" refers to missing printer drivers???

any help is appreciated, thanks!

Top
#139502 - 2005-05-10 07:43 PM Re: AddPrinterConnection fails with error code 2
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
homar76,

Welcome to the board!

What version of Windows are we working on? If it is Windows 9x, ADDPRINTERCONNECTION, SETDEFAULTPRINTER, etc. do not work with Win9x.

Also, what version of KiXtart are you using?

Lastly, can you show the bit of code that is giving you trouble?

Thanks,

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#139503 - 2005-05-11 10:10 AM Re: AddPrinterConnection fails with error code 2
homar76 Offline
Fresh Scripter

Registered: 2005-05-10
Posts: 8
Loc: AUSTRIA
hi,
the script is in use at a windows server 2003, i just use the AddPrinterConnection command (without SetDefaultPrinter):
Code:
  
$pr_single_string = "\\printserver\printer"
If ADDPRINTERCONNECTION ($pr_single_string) = 0
; print
Else
? "Error="+@ERROR
Endif



Version 4.12 of KiXtart is in use.
I checked further the permissions of the user where the script is executed from, the user is local administrator on the machine...

thx!


Edited by homar76 (2005-05-11 10:22 AM)

Top
#139504 - 2005-05-11 05:07 PM Re: AddPrinterConnection fails with error code 2
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
Is "\\printserver\printer" the printer name or the printer share?

You may want to enhance your error checking -
Code:

$pr_single_string = "\\printserver\printer"
If ADDPRINTERCONNECTION ($pr_single_string) = 0
; print
Else ? "Error="+@ERROR @SERROR
Endif



The @SERROR should show us what is going on.

Thanks,

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#139505 - 2005-05-11 06:23 PM Re: AddPrinterConnection fails with error code 2
homar76 Offline
Fresh Scripter

Registered: 2005-05-10
Posts: 8
Loc: AUSTRIA
$pr_single_string = "\\ntalgs10\ph73", where ph73 is the share(&printer) name and ntalgs10 is the printer server.

Result:
Error=2 The system cannot find the file specified.


Edited by homar76 (2005-05-11 06:48 PM)

Top
#139506 - 2005-05-12 01:50 AM Re: AddPrinterConnection fails with error code 2
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
If you hack to the server (Start | Run... | \\ntalgs10) and double-click on ph73 does it add the printer?
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#139507 - 2005-05-12 10:08 AM Re: AddPrinterConnection fails with error code 2
homar76 Offline
Fresh Scripter

Registered: 2005-05-10
Posts: 8
Loc: AUSTRIA
Les, manually adding works, i also added a "ph74" without any problems (like described above, but doing right-click and "connect")...

So now there are two printers installed at the server (called e.g. \\ntalgs09) where the script is running, but when executing there comes still the error 2 message for AddPrinterConnection.

iīm really in desperation...

Top
#139508 - 2005-05-19 08:39 AM Re: AddPrinterConnection fails with error code 2
homar76 Offline
Fresh Scripter

Registered: 2005-05-10
Posts: 8
Loc: AUSTRIA
I have more information about the "phenomen", maybe it helps for further analysis:
The above kix script is configured within a scheduled task with the option "runas user_1" at a windows 2003 server. The task itself is disabled.

Case 1)
a) Logging on remote at the server as user_1
b) Execute the task (right-click->run)
c) Result:
2005/05/19 08:12:46 connection successfull of \\ntalgs10\ph73

Case 2)
a) Logging on remote at the server as user_2 (like user_1 member of the administrator group)
b) Execute the task (right-click->run)
c) Result:
2005/05/19 08:13:57 ErrorCode=2, Error=The system cannot find the file specified.

My conclusion is whenever this task is executed and the specific "runas" user is currently not logged in at the machine, the addprinterconnection command fails. How can i prevent this, please help!

Top
#139509 - 2005-05-19 03:09 PM Re: AddPrinterConnection fails with error code 2
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Printers are added "per user" so you cannot add a printer to a user that is not logged on.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#139510 - 2005-05-19 03:34 PM Re: AddPrinterConnection fails with error code 2
homar76 Offline
Fresh Scripter

Registered: 2005-05-10
Posts: 8
Loc: AUSTRIA
Les, when executing a scheduled task with the "runas" option, the script is executed under that user (and this user is internally logged in as i can see in the event viewer).

I tested the same situation on another server (win2000), there occured no problem with the addprinter command.

Top
#139511 - 2005-05-19 04:06 PM Re: AddPrinterConnection fails with error code 2
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
You said "the specific "runas" user is currently not logged in". Make up your mind. What is it? logged in or not logged in?
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#139512 - 2005-05-19 04:22 PM Re: AddPrinterConnection fails with error code 2
homar76 Offline
Fresh Scripter

Registered: 2005-05-10
Posts: 8
Loc: AUSTRIA
I meant whenever the specific runas user is additionaly logged in remote (via remote desktop connection or terminal server) the script works, when the user is not logged in remote, the addprinterconnection fails (i repeated that more than 3 times)...
Top
#139513 - 2005-05-19 04:33 PM Re: AddPrinterConnection fails with error code 2
maciep Offline
Korg Regular
*****

Registered: 2002-06-14
Posts: 947
Loc: Pittsburgh
So that's still on par with les' earlier post then, right?

Quote:

Printers are added "per user" so you cannot add a printer to a user that is not logged on



Top
#139514 - 2005-05-20 10:00 AM Re: AddPrinterConnection fails with error code 2
homar76 Offline
Fresh Scripter

Registered: 2005-05-10
Posts: 8
Loc: AUSTRIA
no thatīs not the same!
Again:
Case 1)
- Login (remote desktop connection) as user_1,
- Schedule the task at 09:00 for user_1, and logoff
- Login at 09:05 -> failed, Error=2
Case 2)
- Login (remote desktop connection) as user_1,
- Schedule the task at 09:00 for user_1, and watching what happens
-> successfull connected

The scheduled task performs a logon before executing the script, so in my point of view it shouldnīt be necessary that iīm always have an open remote connection to get this script working?!

short paragraph of http://www.windowsecurity.com/articles/Logon-Types.html:
When Windows executes a scheduled task, the Scheduled Task service first creates a new logon session for the task so that it can run under the authority of the user account specified when the task was created. When this logon attempt occurs, Windows logs it as logon type 4.

But obviously my remote connection influences positivly the functionality of this function. I canīt rebuild this behaviour on another server (independent if someone is remote logged in or not the script is working!), so i still asume itīs some specific server setting?!

Top
#139515 - 2005-06-04 02:23 AM Re: AddPrinterConnection fails with error code 2
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
So you're saying the problem is specific to one server and it works correctly on other servers? Then it's not a Kixtart problem.
_________________________
There are two types of vessels, submarines and targets.

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 302 anonymous users online.
Newest Members
Sir_Barrington, batdk82, StuTheCoder, M_Moore, BeeEm
17886 Registered Users

Generated in 0.033 seconds in which 0.011 seconds were spent on a total of 12 queries. Zlib compression enabled.

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