Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I can open "My Computer"..tools..map network drive. Check "Reconnect at logon". And it is permanent. But I may want to clear the shares, and create them quickly. So I want to automatically do a few, so I want a fast way of doing it. I suppose I could write a batch and have it load with the command prompt. Lines like net use V: \\compg\dir But I want the network shares to load automatically when windows starts. I could put the bat in startup folder, but I don't want a command prompt opening up on every windows restart.

I was hoping there might be a command to do it so it is permanent. or perhaps a windows scripting method..

What are my options? I'm interested in what ways this can be done.

share|improve this question
add comment

3 Answers

net use V: \\compg\dir /persistent:yes

is what you are looking for. Same as checking the "Connect automatically at boot" check box.

Also, net use /delete v: to remove it

share|improve this answer
    
hmm, last time I tried that and restarted, it didn't work.. i'll try it again. –  barlop Nov 10 '10 at 18:39
    
according to chicagotech.net/mapping.htm that persistent:yes option is the default. So I think it doesn't do what you think. slight chance it saves login info for next time or something. But it's default according to that link. And we know default doesn't keep the mapping on restart. –  barlop Nov 10 '10 at 18:43
    
@barlop, /persistent:yes in my experience has never been the default, unless that has changed in Win Vista / Win 7. Back in Os/2 days, it wasn't the default, and with Win XP, I always had to add it if I wanted it to persist. –  Benjamin Schollnick Nov 10 '10 at 23:36
1  
It isn't & is the default... From MS: /persistent:{yes | no} : Controls the use of persistent network connections. The default is the setting used last. Deviceless connections are not persistent. Yes saves all connections as they are made, and restores them at next logon. No does not save the connection being made or subsequent connections. Existing connections are restored at the next logon. Use /delete to remove persistent connections. microsoft.com/resources/documentation/windows/xp/all/proddocs/… –  Benjamin Schollnick Nov 10 '10 at 23:37
    
@Benjamin That is an intriguing quote, but what does it mean? Is it the same as "Reconnect at logon" when mapping a network drive via the GUI? I could try it again I suppose. It may be that the mapped drive is not saved, but the logging in aspect is. I want both, and I doubt persistent does that. –  barlop Nov 11 '10 at 1:38
show 2 more comments

Set WshShell = CreateObject("WScript.Shell") WshShell.Run chr(34) & "C:\Yourfile.bat" & Chr(34), 0 Set WshShell = Nothing

Use this in a VBS....reference your path where C:\yourfile.bat is. It pops up a quick vbs screen (maybe half a sec) and you cant close it if you try to in my experience. By the time you try anyway the batch is already launched. Hope this helps

share|improve this answer
    
see my comment to Dennis's answer –  barlop Mar 17 '11 at 3:53
add comment

When I want to do this, I make a shortcut to the batch file then right click on the short cut, select properties, go to the "Shortcut" tab and change the "Run" option from "Normal Window" to "Minimized"

share|improve this answer
    
didn't need a pic ;-) I thought of that - minimized setting, but it's not that seamless and doesn't compare to how it happens automatically if done in the GUI, with no cmd prompt opening every restart. I can probably one-up that in a sense, and hide the command prompt window, using HSTART. or there is a way in vbs, to run a batch file in a hidden command window. I was hoping for other ways though. maybe best way is hiding the cmd window when running a bat, or having a reg file that creates the mapped drives accordingly. –  barlop Nov 10 '10 at 18:32
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.