Solved

Batch Script to find out if a folder exists

Posted on 2008-10-28
3
1,766 Views
Last Modified: 2012-05-05
I am trying to make a simple batch script for windows to find out if a user's folder exists on share on a server. If the folder does not exist, I want it to create one with the user's username. Here is what I have so far.

if not exist \\server\\sharedfolder\%username% md \\server\sharedfolder\%username%

Basically I want to run this as a log on script so a each user can have their own folder on a server, some already have one, so that is why I need to check to see if they have one or not.
0
Comment
Question by:Hector7869
  • 2
3 Comments
 
LVL 38

Accepted Solution

by:
Shift-3 earned 500 total points
ID: 22824030
Assuming that users have sufficient permissions on sharedfolder to create a new folder then that command should work fine.
0
 

Author Comment

by:Hector7869
ID: 22824278

Thats what I thought, for some odd reason it will not make a new folder in my script. If I isolate it and put in a sperate batch file it works, but in my overall script is does not. Here is what the whole batch file looks like. It should check the folder existence first and then create one if it is not there. Then map that folder on the computer.

if not exist \\server4\archive\%username% md \\server4\archive\%username%
 

net use i: \\server2\activefile /user:domain\%username%
net use j: \\server2\archfile /user:domain\%username%
net use t: \\server1\team /user:domain\%username%
net use m: \\server3\users$\%username% /user:domain\%username%
net use l: \\server4\Archive\%username% /user:domain\%username%
 
0
 

Author Comment

by:Hector7869
ID: 22824388
Hmm... I don't know what happened but now it works, I did reset the permission on the shared folder, so mabey that was it. Thanks
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
When you receive another warning that your shared drive is almost full and you have asked your users to clean out old files again and again, here is a single command that may help. This command will place all the files that have not been used rec…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now