[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1283
  • Last Modified:

How to reconnect drives in CMD

Hello, quick question..

Windows XP, CMD running as a different user, launched via runas /user CMD
Did net use * \\server1\share1
The network drives are saved from session to session, but they all become "unavailable".

Is there a way to reconnect all the drives _without_ remapping them (net use P: \\server2\share2)

C:\>net use
New connections will be remembered.

Status       Local     Remote                    Network

-------------------------------------------------------------------------------
Unavailable  E:        \\server1\share1     Microsoft Windows Network
Unavailable  P:        \\server2\share2            Microsoft Windows Network

C:\>net use p:
Local name        p:
Remote name       \\server2\share2
Resource type     Disk
The command completed successfully.

C:\>p:
The system cannot find the drive specified.

Thanks!
0
ViR
Asked:
ViR
  • 3
  • 3
  • 2
  • +1
3 Solutions
 
ggefterCommented:
i would create a script to handle this instead of your method bu i believe what your looking for is this:
If you want the setting to apply to all drives mapped in the login script, then place the following command before any others (note the lack of space between the "persistent", the ":" and the "yes/no")


Survive reboot: net use /persistent:yes
This session only: net use /persistent:no

If you want to set it on a drive by drive case, then use the following commands:


Survive reboot: net use s: \\server1\source /persistent:yes
This session only: net use s: \\server1\source /persistent:no

0
 
ViRAuthor Commented:
Yes, but there is not way to "fix" the situation right now?
0
 
ggefterCommented:
just type this :

net use P: \\server2\share2 /persistant:yes

and that should survive a reboot instead of a single session
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
johnb6767Commented:
If you are doing it in a RunAs, they wont be available to any user, except the one you used to do the RunAs......

They have to be mapped via the proper user to view it.....
0
 
johnb6767Commented:
To clarify, you are logged in as Suzy

Suzy sees the S:  and T: drives, but not M: and J:.

You RUnAs cmd.exe using John's credentials, and mapped M: and J:. You go back to Suzy, and do a net use, M: and J: arent visible, because they are visible to John......

By design...
0
 
Steve KnightIT ConsultancyCommented:
Not entirely sure what you are after here.. but what you could do if the net use is returning "Unavailable" like this is to run a script as that user which picks up any unavailable drives and re-maps them, e.g.

@echo off
for /f "tokens=2,3 delims= " %%a in ('net use ^| find "Unavailable"') do (
  echo Remapping %%c to %%b
  net use %%b /delete 2>NUL
  net use %%b %%c /persistent:yes
)
0
 
ViRAuthor Commented:
Yes, john, ggafter, I understand all that.
My questions is RIGHT NOW, when drives were mapped without "persistent:yes" is there a way to "reconnect" without "remapping"?
0
 
ggefterCommented:
i think th answer your looking for is "NO" not without remapping it
0
 
Steve KnightIT ConsultancyCommented:
My suggestion sort of worked in that it tried to reconnect them but on my own system having tested it seems that you can't re-map because they are "sort of" there.... however doing a

dir p:

for instance despite it showing as Unavailable works fine, though net use still reports Unavailable.  The script I added before was slightly wrong anyway it should have been this, though still can't get it to work for me:

@echo off
for /f "tokens=2,3 delims= " %%a in ('net use ^| find "Unavailable"') do (
  echo Remapping %%b to %%a
  net use %%a /delete 2>NUL
  net use %%a %%b /persistent:yes
)

The intention was to change the runas line to:

runas /user:xxx "cmd.exe /k c:\fixunavailable.cmd"


Steve
0
 
johnb6767Commented:
"i think th answer your looking for is "NO" not without remapping it"

agreed...

Short of

net use \\servername PASSWORD /User:Domain\Userid

Not remapping, just authenticating to the server, without a letter associated....
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 3
  • 3
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now