Using "net use" in Console application

S

SF

How can I call a "net use" command from within my application? I need
to dynamically connect to some remote shares.

Thanks,

Matt
 
G

Galcho[MCSD.NET]

I think it is better to write batch file like

net use %1 %2


where %x are parameters

------

in .NET you can start it using Process.Start("net use ....")

I hope this helps
Galin Iliev[MCSD.NET]
www.galcho.com
 
M

MGH

Galcho said:
I think it is better to write batch file like

net use %1 %2


where %x are parameters

------

in .NET you can start it using Process.Start("net use ....")

I hope this helps
Galin Iliev[MCSD.NET]
www.galcho.com
Can someone point me in the direction of a example of using a batchfile
with parameters?
 
G

Galcho[MCSD.NET]

create file "map.cmd" that contain this:
"net use %1 %2"
without quotes

now you can use it like this

map z: \\server1\share1
map y: \\server1\share2

this is suitable if parameters are frequiently changed. as you can see
this is not very different than usent net use itself
-------------------------
example two:


create single batch file mapAll.cmd that contains


net use z: \\server1\share1
net use y: \\server1\share2

this is most suitable if you do not change letters or network shares

I hope this helps
Galin Iliev[MCSD.NET]
www.galcho.com
 

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