Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating subfolders within pre-existing directory

Status
Not open for further replies.

mgratz

IS-IT--Management
Oct 31, 2012
2
0
0
US
This may be simple and I'm just wording it wrong, but I was unable to find a solution online.

Our computers use security software that resets their local machine (Deep Freeze) data on next reboot. I want to map their Favorites folder to our network drive (F:) instead of their local user profile.

However, none of the current 300 users have a "Favorites" folder in their network "My Documents" Drive. I need a script that will query our F:\users directory and create the "Favorites" subfolder for every single one of their profiles (ie: F:\users\mgratz) within the directory.


Sorry if this is super simple. I'm just currently at a loss.

Thanks,
mgratz
 
I think you are looking for

Code:
set objFSO = CreateObject("Scripting.FileSystemObject")

for each objFolder in objFSO.GetFolder("F:\users").SubFolders
   strFavorites = objFolder.Path & "\Favorites"
   if (!objFSO.FolderExists(strFavorites)) then
      objFSO.CreateFolder strFavorites
   end if
next

-Geates
 
I think the exclamation mark used as the boolean NOT operator is not valid VBScript (but is used in many other programming languages).

The following line
Code:
if ([COLOR=#EF2929]![/color]objFSO.FolderExists(strFavorites)) then

should probably be:
Code:
if ([COLOR=#204A87]Not[/color] objFSO.FolderExists(strFavorites)) then
 
oh, how I wish it was, though. :) Good eye!

-Geates
 
Works great; you guys are superb! Thank you :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top