?
Solved

Batch Script to find out if a folder exists

Posted on 2008-10-28
3
Medium Priority
?
1,775 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 2000 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

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 …
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Suggested Courses

777 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