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 have a task set up to run whenever the computer is logged onto that deletes all network folders and maps a network drive. Here is what is in the batch file:

@echo off
net use * /delete /y
net use b: \\Server\Share /user:DOMAIN\Username password
exit

When the computer is restarted or logged off and back on, the task runs fine (according to the scheduled tasks window saying when it ran last) but the mapped drive doesn't show up. I'll open the command prompt and type "net use" and it simply says "There are no entries in the list". If I then right click on the task and run it, it works and the mapped drive shows up.

I've checked the log and nothing shows up. I've tried adding a timer in the batch file so it waits 10 seconds (ping 1.1.1.1 -n 1 -w 10000>nul) thinking that maybe the network wasn't connected, but that didn't work. What else can I try?

Thanks!

share|improve this question
    
Why would you not use a logon script? –  Dave M Apr 30 '10 at 0:30
    
To be honest, batch files are as fancy as I've ever gone and anything beyond that seems overwhelming. I wouldn't mind learning more if I knew where to start. What would you suggest that is relatively easy for a total beginner to programming that would do what I need? Any other hints would be appreciated too! –  bikefixxer Apr 30 '10 at 0:43
    
Is this system on a domain or in a workgroup? –  Dave M Apr 30 '10 at 0:50
    
Workgroup. Someday I would like to have a domain.... –  bikefixxer Apr 30 '10 at 1:05

2 Answers 2

up vote 0 down vote accepted

What about just putting the batch file in the computer's Startup folder? I can't remember the specifics, but I think the Scheduled Tasks runs under a different context than the Desktop (logged-on user). By putting the batch file in the computer's Startup folder, it will be running under the context of the logged-on user.

share|improve this answer
    
I tried it under all users and under the specific user. It didn't work either way :-( Thanks for trying to help though, I appreciate it. –  bikefixxer Apr 30 '10 at 22:07
    
If the user simply double-clicks the batch file does it map a drive? There should be no difference between that and running through the Startup folder. –  ggutenberg May 1 '10 at 18:35
    
Yes, if the batch file is double-clicked it maps the drive just fine. If it's put in the startup folder, or ran as a scheduled task, or as a logon script it doesn't work. I just don't understand it. Very frustrating. I tried it again and added the timer though, and that seems to work. Thanks for the help! If you have any idea why it won't work earlier during logon I would like to know. –  bikefixxer May 1 '10 at 22:25
    
XP (I'm assuming this is what you're using) starts all services asynchronously. Or, as MS refers to it, it uses "Fast Logon". This lets you log on before all network services are started. See this article - support.microsoft.com/kb/831998 - for more details and how to disable. –  ggutenberg May 2 '10 at 5:44

This will get you started with a startup script and some guidance on logon scripts

Script Help

share|improve this answer
    
The computer I'm having trouble with is running XP home. I have copied the necessary files to make the local security and group policy editors work before, so maybe I'll try that again and see what happens. Question, if I may. It seems like these logon scripts run the same commands as a batch file. What's the difference between a logon script and a scheduled task that runs a batch file? Thanks!!! –  bikefixxer Apr 30 '10 at 1:09
    
The script is the same in many cases. When and how they run is different. –  Dave M Apr 30 '10 at 11:57

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.