Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Setting folder permissions in WSH

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

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Setting folder permissions in WSH
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1] 2   next >   >>
Login
Message << Older Topic   Newer Topic >>
 Setting folder permissions in WSH - 3/14/2005 8:16:22 PM   
  killr0y

 

Posts: 37
Score: 0
Joined: 3/7/2005
From:
Status: offline
Hey guys,

I'm trying to rewrite a batch file using CACLS to a vbs script. Here's what I'd like it to do:

Ask user for a username (%user%)
Create X:\files\%user%
Create \\serverx\text\%user%
Remove allow inheritable permissions (and remove inherited)
add %user% with 'modify' permissions
Copy \\serverx\text\template\text to
\\serverx\text\%user%
Copy X:\files\%user%\*.id to
\\serverx\text\%user%\file\data


Thanks!
 
 
Post #: 1
 
 Re: Setting folder permissions in WSH - 3/15/2005 12:51:20 AM   
  mbouchard


Posts: 1894
Score: 14
Joined: 5/15/2003
From: USA
Status: offline
What do you have so far?

(in reply to killr0y)
 
 
Post #: 2
 
 Re: Setting folder permissions in WSH - 3/15/2005 2:12:23 AM   
  killr0y

 

Posts: 37
Score: 0
Joined: 3/7/2005
From:
Status: offline
I'm using a few non-native DOS executables, namely ask and cacls, which I'm trying to avoid. So basically, taking those out leaves me with some mkdir and xcopy commands. I have no idea how to set permissions using VBS. In fact, I have no idea how to do much of anything in VBS :P

(in reply to killr0y)
 
 
Post #: 3
 
 Re: Setting folder permissions in WSH - 3/15/2005 6:57:10 AM   
  token

 

Posts: 1917
Score: 0
Joined: 1/14/2005
From:
Status: offline
Do you have everything in place (working condition) for the batch file ? If so, I would suggest you to keep it that way. It makes no sense to me to use 2 lines of code in VB to do the same thing that can be done with only 1 line in batch file. Manipulating permissions with file and folder objects is also a hazzle. If you can do the same thing with one line using cacls, why bother with vbs ?

The only thing I think it is worth doing in vbs is the part when it asks for username, so you could possibly do some more "checking" more easily if necessary. Basically, you could just run everything else (besides the first line) in vbs using the RUN method of the SHELL object.

eg:

set shell = createobject("wscript.shell")
user = "some_user_name"
shell.run("Create X:\files\" & user)
shell.run("Create \\serverx\text\" & user)

(in reply to killr0y)
 
 
Post #: 4
 
 Re: Setting folder permissions in WSH - 3/15/2005 7:11:04 PM   
  killr0y

 

Posts: 37
Score: 0
Joined: 3/7/2005
From:
Status: offline
HELP! I've done the folder create/copy stuff, I just need help with how to set the file permissions.. any ideas?

(in reply to killr0y)
 
 
Post #: 5
 
 Re: Setting folder permissions in WSH - 3/15/2005 11:55:43 PM   
  mbouchard


Posts: 1894
Score: 14
Joined: 5/15/2003
From: USA
Status: offline
I agree with Token. If it works in a bat with calcs use that. We use cacls.exe to set folder permissions where I work.

(in reply to killr0y)
 
 
Post #: 6
 
 Re: Setting folder permissions in WSH - 3/15/2005 11:59:51 PM   
  mbouchard


Posts: 1894
Score: 14
Joined: 5/15/2003
From: USA
Status: offline
Ok, I new I had a script from MS doing this and hopefully I can get it all to post. Not sure if there is a limit on length (over 4K lines) but I am going to try. If I can find a link to the script I will edit this post.

Ok, I found that link.

http://support.microsoft.com/?id=825751

(in reply to killr0y)
 
 
Post #: 7
 
 Re: Setting folder permissions in WSH - 3/16/2005 12:21:15 AM   
  killr0y

 

Posts: 37
Score: 0
Joined: 3/7/2005
From:
Status: offline
Thanks for that Mike. Now how do I incorporate this into my script? :P

Sorry for being such a newbie! Here is what I have so far (irrelavent stuff omitted)

MakeFolders.vbs contains:

Blah blah bla...
Set f = fso.CreateFolder(LANPath & UserInput)
Blah blah bla...

So the folder is created in a subfolder on a network share, and I want to change the NTFS permissions of it in the following way:

1) Turn off "allow inheritence", and remove all previously inherited permissions.

2) add UserInput (the user's logon name) with modify permission.

Thanks for all of your help, it is much appreciated!!

(in reply to killr0y)
 
 
Post #: 8
 
 Re: Setting folder permissions in WSH - 3/16/2005 5:48:22 AM   
  mbouchard


Posts: 1894
Score: 14
Joined: 5/15/2003
From: USA
Status: offline
I have not used that script myself so am not sure what would need to be done to incorporate it into your script, but I think that you would call it in a command line from your script just like you would call calcs.exe.

(in reply to killr0y)
 
 
Post #: 9
 
 Re: Setting folder permissions in WSH - 3/16/2005 6:00:32 AM   
  token

 

Posts: 1917
Score: 0
Joined: 1/14/2005
From:
Status: offline
quote:
Originally posted by mbouchard

... but I think that you would call it in a command line from your script just like you would call calcs.exe.



heh.. so why bother getting another vbs file that does the same work as cacls ? Is there a reason why you don't want to use cacls.exe to simply your work ?

(in reply to killr0y)
 
 
Post #: 10
 
 Re: Setting folder permissions in WSH - 3/16/2005 6:18:03 AM   
  token

 

Posts: 1917
Score: 0
Joined: 1/14/2005
From:
Status: offline
Dear God!, I can't believe they use WMI in xcacls.vbs [:0]

(in reply to killr0y)
 
 
Post #: 11
 
 Re: Setting folder permissions in WSH - 3/16/2005 7:59:33 AM   
  esnmb

 

Posts: 448
Score: 0
Joined: 1/11/2005
From: USA
Status: offline
I use vbs but have it call MS RESKIT tool SubInACL.

(in reply to killr0y)
 
 
Post #: 12
 
 Re: Setting folder permissions in WSH - 3/16/2005 9:20:17 AM   
  token

 

Posts: 1917
Score: 0
Joined: 1/14/2005
From:
Status: offline
esnmb, what do you primarily use it for on a regular basis ? I mean, do you use it during the new user creation process or something else ?

(in reply to killr0y)
 
 
Post #: 13
 
 Re: Setting folder permissions in WSH - 3/16/2005 7:52:26 PM   
  killr0y

 

Posts: 37
Score: 0
Joined: 3/7/2005
From:
Status: offline
Ok, I got my script finished but XCACLS isn't working quite the way it should. The only way I could figure out how to make it work was to do a shell.Run to launch the external XCACLS.VBS. The problem with this is that as soon as one shell.Run executes, it goes to the next one before it finishes.. This causes 3 instances of XCACLS to run in parallel which XCACLS apparently doesn't like, so none of the permissions wind up changing.

Any ideas?

(in reply to killr0y)
 
 
Post #: 14
 
 Re: Setting folder permissions in WSH - 3/16/2005 8:57:54 PM   
  killr0y

 

Posts: 37
Score: 0
Joined: 3/7/2005
From:
Status: offline
quote:
Originally posted by token

quote:
Originally posted by mbouchard

... but I think that you would call it in a command line from your script just like you would call calcs.exe.



heh.. so why bother getting another vbs file that does the same work as cacls ? Is there a reason why you don't want to use cacls.exe to simply your work ?



I have to use XCACLS because CACLS doesn't support the /I flag which turns off permission inheritence.. unless theres a new version of CACLS that I don't know about.

(in reply to killr0y)
 
 
Post #: 15
 
 Re: Setting folder permissions in WSH - 3/16/2005 9:28:07 PM   
  killr0y

 

Posts: 37
Score: 0
Joined: 3/7/2005
From:
Status: offline
Ok, What I'm doing now is I'm calling a batch file from my VBS script. The batch script works great. Only problem I have now is how do I pass the "Input" var from my InputBox off to the batch file??

(in reply to killr0y)
 
 
Post #: 16
 
 Re: Setting folder permissions in WSH - 3/16/2005 10:25:26 PM   
  killr0y

 

Posts: 37
Score: 0
Joined: 3/7/2005
From:
Status: offline
Duh.. ok figured it out.. thanks guys!

(in reply to killr0y)
 
 
Post #: 17
 
 Re: Setting folder permissions in WSH - 3/16/2005 11:18:28 PM   
  mbouchard


Posts: 1894
Score: 14
Joined: 5/15/2003
From: USA
Status: offline
quote:
Originally posted by killr0y

Ok, I got my script finished but XCACLS isn't working quite the way it should. The only way I could figure out how to make it work was to do a shell.Run to launch the external XCACLS.VBS. The problem with this is that as soon as one shell.Run executes, it goes to the next one before it finishes.. This causes 3 instances of XCACLS to run in parallel which XCACLS apparently doesn't like, so none of the permissions wind up changing.

Any ideas?


Use wait on return.

Shell.Run "xcacls.vbs",1,TRUE

(in reply to killr0y)
 
 
Post #: 18
 
 Re: Setting folder permissions in WSH - 3/16/2005 11:21:22 PM   
  mbouchard


Posts: 1894
Score: 14
Joined: 5/15/2003
From: USA
Status: offline
quote:
Originally posted by killr0y

quote:
Originally posted by token

quote:
Originally posted by mbouchard

... but I think that you would call it in a command line from your script just like you would call calcs.exe.



heh.. so why bother getting another vbs file that does the same work as cacls ? Is there a reason why you don't want to use cacls.exe to simply your work ?



I have to use XCACLS because CACLS doesn't support the /I flag which turns off permission inheritence.. unless theres a new version of CACLS that I don't know about.


There is a new version of cacls from the 2k res kit
[url]http://www.microsoft.com/windows2000/techinfo/reskit/tools/existing/xcacls-o.asp[/url

(in reply to killr0y)
 
 
Post #: 19
 
 Re: Setting folder permissions in WSH - 3/17/2005 4:13:03 AM   
  token

 

Posts: 1917
Score: 0
Joined: 1/14/2005
From:
Status: offline
quote:
Originally posted by killr0y
I have to use XCACLS because CACLS doesn't support the /I flag which turns off permission inheritence.. unless theres a new version of CACLS that I don't know about.



heh.. You didn't mention that cacls won't turn off permission inheritance, I thought you have EVERYTHING already in place and you just wanted to convert the batch script to vbs.

If you can't get xcacls to work and still interested in doing it using pure vbs, let me know =)

(in reply to killr0y)
 
 
Post #: 20
 
 
Page:   [1] 2   next >   >>
 
  

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 >> Setting folder permissions in WSH Page: [1] 2   next >   >>
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