Command "cd \\server /user:name" doesn't disconnec

Here you can propose new features, make suggestions etc.

Moderators: Hacker, petermad, Stefan2, white

Post Reply
bfu
Junior Member
Junior Member
Posts: 15
Joined: 2009-10-05, 14:17 UTC
Location: Czech Republic

Command "cd \\server /user:name" doesn't disconnec

Post by *bfu »

I use this command in Directory menu (Ctrl+D) this way:
The first item is "cd \\server" and it connects me to the server with my current TC process account name.
The second one is "cd \\server /user:adminuser" and if connection currently doesn't exist, it queries the password for server\adminuser account (there are no domain servers/AD in our network) and then connects me.

But if connection already exists, there is no password query and I stay connected with my current login name.
So, to force the change of the session user I must first manually execute commands "net use \\server\IPC$ /delete", "net use \\server\share1 /delete", "net use \\server\share2 /delete" etc. and then do "cd \\server" or "cd \\server /user:adminuser" (via Directory menu). I have tried this on several combinations of client/server computers (versions of Windows).

I think, that if current session user <> /user parameter, the command SHOULD disconnect and then query for password or display error that it cannot disconnect. And finally, it WOULD be nice to have some comfortable way to do manual disconnection from the given server.
#208434
User avatar
karlchen
Power Member
Power Member
Posts: 4605
Joined: 2003-02-06, 22:23 UTC
Location: Germany

Post by *karlchen »

Hello, bfu.

I disagree on the point that T.C. should automatically logoff a user. If you run the same net use commands at the Windows command prompt, Windows will not log a user off automatically, either. Doing so might be dangerous and cause trouble in case that user is running a job using the account across the network.

Kind regards,
Karl
--
P.S.:
What you write qualifies as a feature request, but not as a bug report. - A bug means that a programme promises to perform an action, but does not do so. Nowhere T.C. promises to perform the actions which you describe.
<corrected>
Incorrect. :oops: The history.txt entry dated 05.01.2010 does state T.C. will autmatically diconnect a connected user. See bfu's post below and the history.txt file of course.
<corrected>
Last edited by karlchen on 2010-04-26, 11:54 UTC, edited 1 time in total.
User avatar
Clo
Moderator
Moderator
Posts: 5731
Joined: 2003-12-02, 19:01 UTC
Location: Bordeaux, France
Contact:

Post by *Clo »

Moderator message

Thread moved to “TC7.55 Suggestions” since there is no bug, but the feature is missing…
Clo, moderator.
#31505 Traducteur Français de TC French translator Aide en Français Tutoriels Français English Tutorials
bfu
Junior Member
Junior Member
Posts: 15
Joined: 2009-10-05, 14:17 UTC
Location: Czech Republic

Post by *bfu »

Hi,
the only reason I reported the TC behaviour as a bug is this item in history.txt:
--
05.01.10 Added: "cd" command in button bar and user menu now accepts parameter /user:, e.g. cd \\server\share /user:username (tries to auto-disconnect first if connection with other user name exists)
--
where "disconnection attempt" is mentioned. If this can be dangerous let's do it TC7.55 Suggestion, I agree.
#208434
User avatar
karlchen
Power Member
Power Member
Posts: 4605
Joined: 2003-02-06, 22:23 UTC
Location: Germany

Post by *karlchen »

Hi, bfu.

I'd say: Oops. :oops: You were right and I was wrong, because I had not read the history.txt carefully enough thus missing the quoted statement.

As the T.C. history states T.C. will do what it does not do, you are right: This might suggest a bug then.
(Even though personally I do not like the idea of automatically disconnecting a user.)
Hm, the history says T.C. were going to try and disconnect a user. It does not say what T.C. will do in case that disconnecting fails for some reason. (Some resources kept busy and locked by the connected user e.g.)

Kind regards,
Karl
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50873
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

TC currently does the following:
1. Call WNetGetUser for the connection to determine the connected user name
2. If the specified user name doesn't contain a backslash \, TC calls GetComputerName, then constructs a name in the form Computername\specified_user
3. If the name returned by WNetGetUser is different, then TC calls WNetCancelConnection(connectionname,false).
4. If WNetCancelConnection returns ERROR_OPEN_FILES or ERROR_DEVICE_IN_USE, TC beeps and doesn't try to connect with new user name

I assume that the connection is still being used, so TC cannot disconnect it.
Author of Total Commander
https://www.ghisler.com
bfu
Junior Member
Junior Member
Posts: 15
Joined: 2009-10-05, 14:17 UTC
Location: Czech Republic

Post by *bfu »

Thank you for your quick response and description. It is (my) marginal problem (with simple workaround - net use /delete) so don't bother trying to resolve this anymore :-)
I only wanted to notice the little discrepancy that TC is not able to disconnect while (possibly multiple) net use /delete succeeds and then I am able to reconnect with different name.
#208434
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50873
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

I assume that net use /delete calls WNetCancelConnection(connectionname,true).

As described on MSDN:
http://msdn.microsoft.com/en-us/library/aa385423%28VS.85%29.aspx

The second parameter "force" tells the function to remove the share even if it is currently in use. Currently I prefer not to do that. Maybe it helps to switch to a local drive before trying to make the connection in TC?
Author of Total Commander
https://www.ghisler.com
bfu
Junior Member
Junior Member
Posts: 15
Joined: 2009-10-05, 14:17 UTC
Location: Czech Republic

Post by *bfu »

To make some conclusion...

First, I don't know the background in the form of Windows API functions.

The aim is to end the server session that is listed on the server in %SystemRoot%\system32\fsmgmt.msc -> Sessions.

I achieve this by multiple net use \\server\xyz executions on the client. But this is not 100% reliable even if I try not to have any open files/dirs. Empty connection listing of "net use" doesn't ensure that the session doesn't exist.
#208434
duvik
New Member
New Member
Posts: 1
Joined: 2012-05-10, 19:25 UTC

force user name

Post by *duvik »

I have the same problem even now. The command
cd \\server /username
was working but after I reinstalled the PC and installed the newest version of TC this does not work any more. I connect the \\server automatically at Windows startup (connect network drive) but I am unable to connect to this server with a different user name.
Would you have a solution?
Post Reply