AddPrinterConnection

P

PBartolini

by,
I have a problem with "AddPrinterConnection"
I have a user that is local (he is not in the NT domain) but he has to
use some CD and printer of the net.
I have made a logon script in VB to connect the local user to the net
using a network userID and password).
when I disconnect/connect the drive it is OK but when I use the script
to dinamically disconnect and reconnect the printe the scipt fail and
I see:
"An Attempt Was Made to Remember a Device That Had Previously Been
Remembered".

I have W2k with SP4
I have find, in the web, that it is a problem resolved by SP4 but I
HAVE SP4!

the script is the following:

Private Sub Form_Load_bak()
On Error GoTo G_Errore
Set objNetwork = CreateObject("WScript.Network")
objNetwork.RemoveNetworkDrive "F:"
objNetwork.RemoveNetworkDrive "I:"
objNetwork.RemoveNetworkDrive "J:"
objNetwork.RemoveNetworkDrive "L:"
objNetwork.RemovePrinterConnection "LPT1:"
'IN THE ABOVE LINES I HAVE NOT ERRORS!

Segue:
RetVal = InputBox("UserID", , "BiblioPub")
RetVal1 = InputBox("Password", , "Pubblico")
RetVal2 = InputBox("Printer", , "\\serv-biblioteca\HPLaserJ")
CONNS = RetVal2

'IN THE FOLLOWING LINE THERE IS THE ERROR!
objNetwork.AddPrinterConnection "LPT1", CONNS, False, RetVal,
RetVal1

'IN THE FOLLOWING LINES I HAVE NOT ERRORS!
CONNS = C_ALICE: objNetwork.MapNetworkDrive "J:", CONNS, False,
UTENTE, PSW
CONNS = C_BNI: objNetwork.MapNetworkDrive "L:", CONNS, False,
UTENTE, PSW
CONNS = C_UOL: objNetwork.MapNetworkDrive "F:", CONNS, False,
UTENTE, PSW
CONNS = C_CLIO: objNetwork.MapNetworkDrive "I:", CONNS, False,
UTENTE, PSW
End
Exit Sub
G_Errore:
If Err.Number = -2147022646 Then Resume Next
Resume Next
End
Exit Sub
End Sub

I have the error only in the "AddPrinterConnection".
the user can be an administrator or a normal user, it's the same.
the domain is a NT domain.
the user system is win 2000 sp4.

Someone can help me?

thanks

Paolo
 
M

Mark-Allen Perry

First, strip out all but the printer-related code. Then hard code the correct responses to the questions and see if this works.

Also, display the values passed with a '[' and ']' to show where the values begin and end.

Another check is to 'force' the printer removal. Check the docs for this.

Post the results. I'd like to know also.

--
And always try the MS KB first before posting.
The answer is probably already posted.
MS KB: http://support.microsoft.com/default.aspx?scid=fh;EN-US;KBHOWTO
----
Mark-Allen Perry
ALPHA Systems
Marly, Switzerland
mark-allen_AT_mvps_DOT_org

by,
I have a problem with "AddPrinterConnection"
I have a user that is local (he is not in the NT domain) but he has to
use some CD and printer of the net.
I have made a logon script in VB to connect the local user to the net
using a network userID and password).
when I disconnect/connect the drive it is OK but when I use the script
to dinamically disconnect and reconnect the printe the scipt fail and
I see:
"An Attempt Was Made to Remember a Device That Had Previously Been
Remembered".

I have W2k with SP4
I have find, in the web, that it is a problem resolved by SP4 but I
HAVE SP4!

the script is the following:

Private Sub Form_Load_bak()
On Error GoTo G_Errore
Set objNetwork = CreateObject("WScript.Network")
objNetwork.RemoveNetworkDrive "F:"
objNetwork.RemoveNetworkDrive "I:"
objNetwork.RemoveNetworkDrive "J:"
objNetwork.RemoveNetworkDrive "L:"
objNetwork.RemovePrinterConnection "LPT1:"
'IN THE ABOVE LINES I HAVE NOT ERRORS!

Segue:
RetVal = InputBox("UserID", , "BiblioPub")
RetVal1 = InputBox("Password", , "Pubblico")
RetVal2 = InputBox("Printer", , "\\serv-biblioteca\HPLaserJ")
CONNS = RetVal2

'IN THE FOLLOWING LINE THERE IS THE ERROR!
objNetwork.AddPrinterConnection "LPT1", CONNS, False, RetVal,
RetVal1

'IN THE FOLLOWING LINES I HAVE NOT ERRORS!
CONNS = C_ALICE: objNetwork.MapNetworkDrive "J:", CONNS, False,
UTENTE, PSW
CONNS = C_BNI: objNetwork.MapNetworkDrive "L:", CONNS, False,
UTENTE, PSW
CONNS = C_UOL: objNetwork.MapNetworkDrive "F:", CONNS, False,
UTENTE, PSW
CONNS = C_CLIO: objNetwork.MapNetworkDrive "I:", CONNS, False,
UTENTE, PSW
End
Exit Sub
G_Errore:
If Err.Number = -2147022646 Then Resume Next
Resume Next
End
Exit Sub
End Sub

I have the error only in the "AddPrinterConnection".
the user can be an administrator or a normal user, it's the same.
the domain is a NT domain.
the user system is win 2000 sp4.

Someone can help me?

thanks

Paolo
 
P

PBartolini

Mark-Allen Perry said:
First, strip out all but the printer-related code. Then hard code the
correct responses to the questions and see if this works.

I tried but it doesn't work!

Also, display the values passed with a '[' and ']' to show where the
values begin and end.

scuse me, I don't understand when you say this. can you explain
better?

Another check is to 'force' the printer removal. Check the docs for
this.
I have already try, but it is the same.



I tried to find in the microsoft KB but, for bill gates, the problem
is resolved with the SP4...:)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top