Member Login

Remember Me
Forgot Password?
Join Us!

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.
Jobs from Indeed

Link To This Forum!

Partner Button
Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

batch command won't run at startup - reconnect network drive

batch command won't run at startup - reconnect network drive

Hi folks! I have two problems that are probably pretty common on XP. First is that I need to have a network drive accessible upon system startup (it's an XP server that needs to reboot daily). It is ostensibly connected automatically at startup but remains inaccessible to the program that needs it until I manually open the folder location. I want to automate this task, and have read that the most common solution is to explicitly connect to the drive using the 'net use' command in a batch file and run it at system startup. The second problem is that the 'net use' command works as desired to make the drive accessible when I launch it myself by double-clicking the batch file, but does not work when I run it as a startup command. The other program runs fine from the batch, but fails because it cannot access the drive. Argh! How is it that double-clicking the batch file works for net use, but putting it in the startup folder does not? Help greatly appreciated!

RE: batch command won't run at startup - reconnect network drive

A couple of ideas for you to look at.

Can you make any use of this Policy Setting?

The policy "Always wait for the network at computer startup and logon" is found:

Computer Configuration/  Administrative Templates/  System/  Logon

What if you used Scheduled Tasks to run any Batch File, rather than the Startup Folder.  You may have to give the task Administrative Permissions?

RE: batch command won't run at startup - reconnect network drive

Thanks, linney, for your suggestions. The scheduled tasks idea I had tried already, but unfortunately that had the same result as the startup menu option.

The Policy Setting idea was a good one, though, and I hadn't thought about that one. Unfortunately, I enabled that option, rebooted several times and still no luck.

At the moment, I'm finding myself longing for the cron and shell scripting of the unix environment to which I'm accustomed. Windows can get tricky for this more technical stuff!

RE: batch command won't run at startup - reconnect network drive

BBB: thanks for that tip. I went ahead and gave it a try, and it seems like a useful setting for my purposes anyway, but I don't think it directly relates to this startup issue. It looks to be more of an inactivity timeout concern. It did point me in the direction of a few more registry tweaks I could try. Thanks for the input.

RE: batch command won't run at startup - reconnect network drive

Perhaps it is a startup order issue..The batch file may be trying to set up the net use link before the needed prerequisite services are running.



To Paraphrase:"The Help you get is proportional to the Help you give.."

RE: batch command won't run at startup - reconnect network drive

Maybe any batch file might benefit from a timeout delay or sleep command?


RE: batch command won't run at startup - reconnect network drive

Put the NET USE command in the same batch file that runs the other program.  Precede it with a NET USE /DELETE command so that it does not fail.

RE: batch command won't run at startup - reconnect network drive

Very helpful suggestions, all. I will have to wait until midafternoon my time to test this again. I will report back with my findings!

RE: batch command won't run at startup - reconnect network drive

I agree with webrabbit.
If you already execute a batch/command file, add the "net use" command in it as a prior step.
Or, call the batch file that issues the net use from the file.

RE: batch command won't run at startup - reconnect network drive

Currently, I have all the commands running from one batch script in the startup folder. The script currently waits for 10 seconds, then issues the net use command (which I have verified works to reconnect the drive)(I tried it with the /delete option, but that threw back an error message, will have to look more into it. For now, I'm running it with a start /wait command which ensures other processes do not run before it has completed) and then launches my program. No luck with this setup.

I also tried the "Delay mounting network drive at boot" link but it's for Win7 and the netlogon.bat file location/behavior is different for windows XP. That's another lead I'll research further. I'll have to do some more dicking around and report back! Thanks again for the continued suggestions.


RE: batch command won't run at startup - reconnect network drive

OK, using the last script (see below) from the WINDOWS 7 link (see above), and saving it out as TEST.BAT, placed under C:\ (can be actually anyplace) and using the MMC to create a GroupPolicy startup script policy, works on my test XP system...



@echo off
set ServerIP=
ping %ServerIP% -n 2 | find /i "bytes=" > nul && goto Connect
ping localhost -n 180 > nul
goto Loop

net use S: \\%ServerIP%\ShareName


How to: Add startup and shutdown scripts in Windows

"If it works don't fix it! If it doesn't use a sledgehammer..."
How to ask a question, when posting them to a professional forum.
Only ask questions with yes/no answers if you want "yes" or "no"

RE: batch command won't run at startup - reconnect network drive

Thanks, BBB and everyone, for all of your time investment into helping me solve this problem. Unfortunately, I tried the script and the group policy startup approach and still no dice. I have now, through additional testing, been able to confirm that the network drive is simply unavailable to the program until the desktop is shown - it's not listed as a potential drive. I've run the application that needs it in debugging mode, and it pops up a window during startup asking for the drive, and it's just not there. If I run your script from the .bat file myself after I've fully booted into the desktop, it works immediately. Very strange indeed. I'm not sure what other boot-order steps there are to try, but I'm starting to wonder if this specific application does not handle networking gracefully. I'd first thought it was an OS issue, but I'm starting to wonder. May have to contact the devs on Monday.

RE: batch command won't run at startup - reconnect network drive

Another thought that just occurred to me: the app seems to be heavily reliant on the .NET framework, and I've heard of that bringing its own kettle of fish with it. Any possibility I might have to pass some commands the framework in the startup script? I know all of nothing about .NET.

RE: batch command won't run at startup - reconnect network drive

Just thought I'd follow up with the solution that finally worked: I found these two registry entries:


Name: RestoreConnection
Value: 1


Name: EnableLinkedConnections
Value: 1

Had to make a new entry for one, changed the other from 0 to 1 and it worked like a charm! Haven't tested them individually to see if only one was needed, so if you're the cautious type, try first one and then the other. After changing these, no startup script was necessary - I just put the app in the startup folder and I was up and running. Apparently, these work in Vista and Windows 7 as well.

For a very good thread that turned me on to these (and has many helpful suggestions), see

Many thanks again to all who gave helpful input into this thread, and I hope somebody is helped by this info!

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close