Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Help needed with folder creation and permission

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,61577
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Help needed with folder creation and permission
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Help needed with folder creation and permission - 6/18/2008 5:18:43 AM   
  goody3335

 

Posts: 2
Score: 0
Joined: 6/18/2008
Status: offline
I would like to use a logon script that will create a folder for a user on a different server, if that folder doesn't already exist.  It will also assign proper permissions to that folder.  I have the following script, but it's not working.  Any suggestions?

Set objNet = WScript.CreateObject("WScript.Network")
Set FSO = CreateObject("scripting.filesystemobject")
sUserName = objNet.UserName
sDomainName= objNet.UserDomain
folderToCheckFor = "\\clt-ftptest\tyler-ftp\users" & sUserName
If (FSO.FolderExists(folderToCheckFor)) = False Then
   FSO.CreateFolder(folderToCheckFor)
   Set WshShell = WScript.CreateObject("WScript.Shell")
   Call WshShell.Run("CACLS " & folderToCheckFor & " /T /E /C /G " & sDomainName & "\" & sUserName & ":F",2,True)
   Call WshShell.Run("CACLS " & folderToCheckFor & " /T /E /C /G " & sDomainName & "\Domain Admins:F",2,True)
   Call WshShell.Run("CACLS " & folderToCheckFor & " /T /E /C /G " & sDomainName & "\GLOBAL_SUPERVISORS:F",2,True)
   Set WshShell = nothing
End If
Set FSO = nothing
Set objNet = nothing
 
 
Post #: 1
 
 RE: Help needed with folder creation and permission - 6/18/2008 5:29:07 AM   
  ebgreen


Posts: 5041
Score: 31
Joined: 7/12/2005
Status: offline
"but it's not working"

What's not working? Errors? No errors? Does it make the folder? Is it not permissioning?

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to goody3335)
 
 
Post #: 2
 
 RE: Help needed with folder creation and permission - 6/18/2008 5:34:05 AM   
  goody3335

 

Posts: 2
Score: 0
Joined: 6/18/2008
Status: offline
I logon using the test user's name and I get no errors.  It just doesn't create the folder
If I just double click on the script that I have on the domain controller it gives me the error:
Line: 9
char: 5
Error: Permission Denied
Code: 800A0046
Source: Microsoft VBScript runtime error

I've given the user write permissions on the Users folder, though.  Do they need more permissions?  Forgive me, I'm new.

(in reply to ebgreen)
 
 
Post #: 3
 
 RE: Help needed with folder creation and permission - 6/18/2008 10:16:44 PM   
  Raevan

 

Posts: 1
Score: 0
Joined: 6/18/2008
Status: offline
quote:

ORIGINAL: goody3335

I would like to use a logon script that will create a folder for a user on a different server, if that folder doesn't already exist.  It will also assign proper permissions to that folder.  I have the following script, but it's not working.  Any suggestions?

Set objNet = WScript.CreateObject("WScript.Network")
Set FSO = CreateObject("scripting.filesystemobject")
sUserName = objNet.UserName
sDomainName= objNet.UserDomain
folderToCheckFor = "\\clt-ftptest\tyler-ftp\users" & sUserName
If (FSO.FolderExists(folderToCheckFor)) = False Then
FSO.CreateFolder(folderToCheckFor)
Set WshShell = WScript.CreateObject("WScript.Shell")
Call WshShell.Run("CACLS " & folderToCheckFor & " /T /E /C /G " & sDomainName & "\" & sUserName & ":F",2,True)
Call WshShell.Run("CACLS " & folderToCheckFor & " /T /E /C /G " & sDomainName & "\Domain Admins:F",2,True)
Call WshShell.Run("CACLS " & folderToCheckFor & " /T /E /C /G " & sDomainName & "\GLOBAL_SUPERVISORS:F",2,True)
Set WshShell = nothing
End If
Set FSO = nothing
Set objNet = nothing


Seems you're calling the wrong path in your script:

folderToCheckFor = "\\clt-ftptest\tyler-ftp\users" & sUserName
 

      

Try that...

EDIT: And yes, I did join just to tell you that :p

(in reply to goody3335)
 
 
Post #: 4
 
 RE: Help needed with folder creation and permission - 6/18/2008 11:45:11 PM   
  ninjamaster

 

Posts: 107
Score: 0
Joined: 1/23/2007
Status: offline
Agreed. Line 9 says

Call WshShell.Run("CACLS " & folderToCheckFor & " /T /E /C /G " & sDomainName & "\" & sUserName & ":F",2,True)

Your trying to change the permissions on \\clt-ftptest\tyler-ftp\users folder that I'm guessing your user doesn't have rights. You need to add after folderToCheckFor the users folder (sUserName)

I also had problems with using the CACLS command through VBS but found an online doc that helped. If you also have probs try changing the CACLS line to mirror


objShell.run "cmd /c echo y|CACLS " and then all your paths and permissions.

:)

(in reply to Raevan)
 
 
Post #: 5
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Help needed with folder creation and permission Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts