Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Alternative to MapNetworkDrive method 1

Status
Not open for further replies.

1DMF

Programmer
Jan 18, 2005
8,795
GB
I cannot get the MapNetworkDrive method under the network API to work.

Can I use another API and issue a net use command instead?

Any guidance appreciated.

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!
 
You may use the WshShell.Run "net use ..." method.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
thanks, do I need to create a shell object?

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!
 
do I need to create a shell object
If your actual script didn't have created one yet then obviously yes.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
sorry but i've never witten this stuff before, it's no good assuming I know something!

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!
 
it's no good assuming I know something
Sorry, but you seems to do VBS since at least 12 Jul 06 ...
 
huh? where on earth do you work that out from, I wrote a script, the one and only script in VBScript I have ever written over 2 years ago, that no longer works, and all of a sudden i've become an expert?

I wish!

.........anyhow........

can someone advise the correct syntax for the net use via VBScript and the shell command, also why the error traping routine isn't working?

Code:
objShell.Run "net use H: '\\server\folder', 'UserID', 'Password'"   

If Err.Number <> 0 Then      
	ErrText = "(" & Err.Number & ") " & Err.Description       
	Error_Msg ErrText  
	WScript.Quit
End If

The drive isn't being mapped, but the Err.Number must = 0 else it would trap the error, which it isn't?

Does Shell.Run not affect VBScripting Error Handling?

being a complete and utter novice, this is proving to be rather difficult, regardless of what some might think ;-)

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!
 
As I said PHV - those threads all relate to this one script written over two years ago ;-)

Thanks for the syntax, though what's wierd is now the error trapping doesn't work, plus the removenetworkdrive doesn't work!

So I guess I'll have to use the shell.runn net use command to delete the drive once finished.

Seems odd that the removenetworkdrive only works if the drive was connected with mapnetworkdrive.

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!
 
nope didn't work, and what's even worse is now the error trapping doesn't work either.

so we tried a different machine @ Malta, that ran fine with the original script.

so we then tried another machine at the clients location back in UK and now I can't get the user cert to install from certificate services to set up the VPN connection, which i've opened a new thread for.

Thanks for the syntax, shame it didn't fix the problem, and now i've got even more problems, hey ho, never rains does it!

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top