Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have at the moment a logon.cmd script, that I'm using to map network drives to the users profile. It looks like this:

net use m: /delete
net use m: \\BOB\onboarding 
net use n: /delete
net use n: \\BOB\bookings 

net use j: /delete
net use j: \\BOB\accounts 

It works fine up until it gets up to a folder that the current user cannot access, it then asks for a username and password instead of erroring and continuing.

Notes: This very script used to work on another Samba PDC network, but I've moved it over to another server (Still Samba PDC) and now its breaking.

Is there anyway for it to ignore the username/password prompt and just continue?

share|improve this question
Gotta ask - Why are you running a script to map drives that the user may not have a access to? – John Gardeniers Oct 16 '12 at 6:24
Logon.cmd is the only script that can be ran during boot, and it has no way of knowing who should have access to what, so, it has to try to map everything otherwise it would get skipped – Mattisdada Oct 16 '12 at 8:25
I don't use Samba, so I'm not fully familiar with it, but are you saying that all users must have the same script? Can't you set a logon script on a per-user basis? – John Gardeniers Oct 16 '12 at 12:23
Unfortunately no :/, Samba is a lot more basic than your normal AD PDC, you have one script for everyone on logon. – Mattisdada Oct 17 '12 at 2:34
And this is a prime example of why it's usually not a good idea to try and replace Active Directory with something that isn't Active Directory. – MDMarra Oct 26 '12 at 2:19

Extending Mattisdada's answer, this script will make it a bit easier to modify any drive mappings by simply adding, deleting or changing the mapDrive function calls. Additionally, this function checks for read access by calling DIR (instead of writing the temp file) and maps accordingly:

@ECHO off

CALL:mapDrive K: helpdesk
CALL:mapDrive M: onboarding
CALL:mapDrive Z: watercooler

net use
ECHO Mapping Complete. Thank You.

DIR \\%SHARE%\%~2 > nul 2>&1
    net use %~1 /DELETE > nul 2>&1
    net use %~1 \\%SHARE%\%~2
share|improve this answer
up vote 2 down vote accepted

I was never able to find a finite solution to the problem. But a usable (but very hacky and unclean) work around is using this command:

copy /Y NUL "\\BOB\helpdesk\.writable"
    del \\BOB\helpdesk\.writable

net use k: /delete
net use k: \\BOB\helpdesk 

copy /Y NUL "\\BOB\onboarding\.writable" 
    del \\BOB\onboarding\.writable

net use m: /delete
net use m: \\BOB\onboarding 


Basic explanation: It checks to see if a folder is writeable first by coping a blank file .writable, if it succeeds it executes the command, if it fails it skips the command and continues on.

This is purely a workaround....

share|improve this answer
Hey @Mattisdada, I'm adding an answer that extends yours. Maybe a community wiki would make sense here; I'm not sure. Thanks for posting question/answer. Your solution was the best fix I could find for my problem and I just hope my answer can add a little value. – bnjmn May 30 '13 at 20:22

Your Answer


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.