Solved

Batch Script to find out if a folder exists

Posted on 2008-10-28
3
1,774 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Enroll in June's Course of the Month

June's Course of the Month is now available! Every 10 seconds, a consumer gets hit with ransomware. Refresh your knowledge of ransomware best practices by enrolling in this month's complimentary course for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If like me you are one who spends a lot of time working and scripting with cmd.exe, sometimes it is handy to be able to quickly view a calendar for a given month and year. This script will quickly do just that!  Save the code posted below to a .bat …
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

707 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