views:

796

answers:

5

windows only record 1 user/pwd to a remote share dir,

and my program need to connect a dir,

but the user may login first, let my program failed to connect,

is there a method to disconnect it? i only know the IP.

I use wnetcancelconnection2(remotedir) first, but still cannot work,

and return 1219 error(credentials supplied conflict with an existing set of credentials)

A: 

net use \\10.0.0.1\sharename /user:domain\user

to disconnect

net use \\10.0.0.1\sharename /delete

sipwiz
not the command-line way, but the programming way.
linjunhalida
A: 

To disconnect one single computer/ip from a share. Use net session \IPADDRESS OR NAME /Delete or Net Session /delete to disconnect all client connections. You must run this command from the server which holds the share that is being connected to.

Of course im not quite sure i read your question correctly.

A: 

See source code for "net use"

Is it open-source?
Anonymous
@limace - No it's not!
Isaac
A: 

Have you tried the NetUseDel function?

NetUseDel Function

wkf
A: 

sipwiz is right :

net use \10.0.0.1\sharename /user:domain\user

to disconnect

net use \10.0.0.1\sharename /delete

(sorry sipwiz, can't vote for your answer yet ...)

Thomas