Link to home
Start Free TrialLog in
Avatar of Joesmail
Joesmail

asked on

using IWshRuntimeLibrary in C#

Hi Experts,

I would like to know how to use the using WshNetworkClass.....to safely Add Printers and Map a Network Drive.

I have managed to Add a printer passing it "" values for driver & port, although when I try to MapNetworkDrive I don't know what I should be supplying the ref objects?

Can anyone help me with this please...

Thanks in advance.
Avatar of Jagadeesh M
Jagadeesh M
Flag of United States of America image

Avatar of Joesmail
Joesmail

ASKER

To be clearer....I am trying to map a drive using the following library....

using IWshRuntimeLibrary;
...
...
WshNetworkClass network = new  WshNetworkClass();
...
...
network.MapNetworkDrive(_drive,  @"\\" + _server + @"\" + _share,REF OBJECT, REF OBJECT, REF OBJECT);

Can anyone give me some examples of the REFs required here........
i guess this works in VBScript. It should successfully map to a network drive
\\server1\data.


Dim WshNetwork
Set WshNetwork = WScript.CreateObject("WScript.Network")
sPwd = inputbox("Enter password")
WshNetwork.MapNetworkDrive "J:", "\\server1\data", false,
"xyz_net\John", sPwd
Msgbox "Drives has been mapped successfully"
you guessed wrong.
ASKER CERTIFIED SOLUTION
Avatar of gregoryyoung
gregoryyoung
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks for this gregoryyoung

Just one last question.  Do you know if there is a way around having to PASS the password.  I can identify the username easily enought Environment.Username although I don't know how I would pass the "password" credentials through?
I would imagine that is if you want to use a different username/pass (without knowing the library). My guess would be that passing null attempts to use your current token (but this is just a guess)