Friday, April 15, 2011

how to disconnect a windows share dir by known IP?

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)

From stackoverflow
  • net use \\10.0.0.1\sharename /user:domain\user

    to disconnect

    net use \\10.0.0.1\sharename /delete

    linjunhalida : not the command-line way, but the programming way.
  • 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.

  • See source code for "net use"

    Anonymous : Is it open-source?
    Isaac : @limace - No it's not!
  • Have you tried the NetUseDel function?

    NetUseDel Function

  • 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 ...)

0 comments:

Post a Comment