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.

The system cannot find the drive specified.

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

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

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

and that should survive a reboot instead of a single session
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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"?
i think th answer your looking for is "NO" not without remapping it
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"

"i think th answer your looking for is "NO" not without remapping it"


Short of

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

Not remapping, just authenticating to the server, without a letter associated....
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows XP

From novice to tech pro — start learning today.