Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Set NTFS permissions

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

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Set NTFS permissions
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1] 2 3   next >   >>
Login
Message << Older Topic   Newer Topic >>
 Set NTFS permissions - 4/6/2005 2:44:27 PM   
  Sir Suckalot

 

Posts: 25
Score: 0
Joined: 3/14/2005
From: Canada
Status: offline
I'm looking for a way to set NTFS permissions on a newly created user's personal folder. To do this, I tried using xcacls which works great when used in it's normal form

Ex. wsh.run "xcacls \\Servername\JoeShmoe /I REMOVE /T /S /F /G Domain\JoeShmoe:F /Q"

If I try putting in a variable to set UserName and userPersonalFolder (they have the same name), I get a bad syntax error.

Here's my question; what would be the correct syntax to replace JoeShmoe in my example by a variable called Username? Is there a better way of setting NTFS permissions using Vbs?
 
 
Post #: 1
 
 Re: Set NTFS permissions - 4/6/2005 2:57:49 PM   
  token

 

Posts: 1917
Score: 0
Joined: 1/14/2005
From:
Status: offline
Replace:

wsh.run "xcacls \\Servername\JoeShmoe /I REMOVE /T /S /F /G Domain\JoeShmoe:F /Q"

with:

wsh.run "xcacls \\Servername\" Username & " /I REMOVE /T /S /F /G Domain\" & Username & ":F /Q"

(in reply to Sir Suckalot)
 
 
Post #: 2
 
 Re: Set NTFS permissions - 4/6/2005 3:03:14 PM   
  Sir Suckalot

 

Posts: 25
Score: 0
Joined: 3/14/2005
From: Canada
Status: offline
I'm getting a "expected end of statement" error when I run my script with this syntax...

(in reply to Sir Suckalot)
 
 
Post #: 3
 
 Re: Set NTFS permissions - 4/7/2005 1:09:06 AM   
  Country73


Posts: 712
Score: 8
Joined: 8/25/2004
From: USA
Status: offline
Replace:

wsh.run "xcacls \\Servername\" Username & " /I REMOVE /T /S /F /G Domain\" & Username & ":F /Q"

with
wsh.run "xcacls \\Servername\" & Username & " /I REMOVE /T /S /F /G Domain\" & Username & ":F /Q"

Missed the extra '&' before Username

(in reply to Sir Suckalot)
 
 
Post #: 4
 
 Re: Set NTFS permissions - 4/7/2005 1:21:55 AM   
  token

 

Posts: 1917
Score: 0
Joined: 1/14/2005
From:
Status: offline
My bad =)

(in reply to Sir Suckalot)
 
 
Post #: 5
 
 Re: Set NTFS permissions - 4/7/2005 1:22:03 AM   
  cjwallace

 

Posts: 491
Score: 0
Joined: 3/5/2005
From: United Kingdom
Status: offline
Hi Guys, i am trying to do something similar with the users profile.

Below is my code but i dont know why its not running. I am also still learning VBScript.

wsh.run "xcacls h:\Profile /t /e /G LONDON\ADMINISTRATOR:F LONDON\DOMAIN ADMINS:F LONDON\DOMAIN USERS:RCEW LONDON\HELPDESK:F /C /Y"

When i run the above code i get,

Error Object doesn't support this property or method: 'wsh.run' i can only think that wsh.run is not the right command.

Thanks in advance for your help

(in reply to Sir Suckalot)
 
 
Post #: 6
 
 Re: Set NTFS permissions - 4/7/2005 1:26:09 AM   
  token

 

Posts: 1917
Score: 0
Joined: 1/14/2005
From:
Status: offline
Post your code related to the declaration of wsh object.

(in reply to Sir Suckalot)
 
 
Post #: 7
 
 Re: Set NTFS permissions - 4/7/2005 1:31:42 AM   
  cjwallace

 

Posts: 491
Score: 0
Joined: 3/5/2005
From: United Kingdom
Status: offline
Hi Token: it is

Set wsh = CreateObject("WScript.Shell")
wsh.run "xcacls h:\Profile /t /e /G LONDON\ADMINISTRATOR:F LONDON\DOMAIN ADMINS:F LONDON\DOMAIN USERS:RCEW LONDON\HELPDESK:F /C /Y"

Thanks in advance

(in reply to Sir Suckalot)
 
 
Post #: 8
 
 Re: Set NTFS permissions - 4/7/2005 1:37:21 AM   
  token

 

Posts: 1917
Score: 0
Joined: 1/14/2005
From:
Status: offline
I can't see any problems with that line. If you running that from ASP, you might encounter problems and might need to lower the security policies in IE.

(in reply to Sir Suckalot)
 
 
Post #: 9
 
 Re: Set NTFS permissions - 4/7/2005 2:04:06 AM   
  cjwallace

 

Posts: 491
Score: 0
Joined: 3/5/2005
From: United Kingdom
Status: offline
Hi Token, Well i am running it on Windows 2000 SP4, this is not another one of them "will only run on XP" things is it?

when i run it now i get

Microsoft VBScript runtime error: Wrong number of arguments or invalid property assignment: 'wsh'

(in reply to Sir Suckalot)
 
 
Post #: 10
 
 Re: Set NTFS permissions - 4/7/2005 2:24:13 AM   
  cjwallace

 

Posts: 491
Score: 0
Joined: 3/5/2005
From: United Kingdom
Status: offline
Token: I have changed the script as per below. The script run + i DONT get any error messages but it does not change my permisssions. Is this the right type of code to use for what i am trying to do?

Set shell = CreateObject("wscript.shell")
shell.run "xcacls h:\Profile /t /e /G LONDON\ADMINISTRATOR:F LONDON\DOMAIN ADMINS:F LONDON\DOMAIN USERS:RCEW LONDON\HELPDESK:F /C /Y"

Thanks for your help

(in reply to Sir Suckalot)
 
 
Post #: 11
 
 Re: Set NTFS permissions - 4/7/2005 6:02:59 AM   
  token

 

Posts: 1917
Score: 0
Joined: 1/14/2005
From:
Status: offline
Does ""xcacls h:\Profile /t /e /G LONDON\ADMINISTRATOR:F LONDON\DOMAIN ADMINS:F LONDON\DOMAIN USERS:RCEW LONDON\HELPDESK:F /C /Y" actually change the permission if executed manually ?

Also, you might want to add "cmd /c" before "xcacls.......", and leave space in between the 2.

(in reply to Sir Suckalot)
 
 
Post #: 12
 
 Re: Set NTFS permissions - 4/7/2005 7:20:53 AM   
  cjwallace

 

Posts: 491
Score: 0
Joined: 3/5/2005
From: United Kingdom
Status: offline
Token. Hi mate, thanks for the reply.

if i run xcacls h:\Profile /t /e /G LONDON\ADMINISTRATOR:F LONDON\DOMAIN ADMINS:F LONDON\DOMAIN USERS:RCEW LONDON\HELPDESK:F /C /Y from a batch file it is fine i will give the "cmd /c" a go when i get in the office tomorrow......will let you know how i get on

Thanks again

(in reply to Sir Suckalot)
 
 
Post #: 13
 
 Re: Set NTFS permissions - 4/7/2005 7:51:27 AM   
  token

 

Posts: 1917
Score: 0
Joined: 1/14/2005
From:
Status: offline
Ok, I was wondering if the space in the group name (DOMAIN ADMINS and DOMAIN USERS) was the cause of the problem.

(in reply to Sir Suckalot)
 
 
Post #: 14
 
 Re: Set NTFS permissions - 4/7/2005 8:52:51 AM   
  Sir Suckalot

 

Posts: 25
Score: 0
Joined: 3/14/2005
From: Canada
Status: offline
CjWallace: You have to put the filename and username between quotation marks if they contain spaces. Go to cmd prompt and type xcacls ? for more info.

(in reply to Sir Suckalot)
 
 
Post #: 15
 
 Re: Set NTFS permissions - 4/7/2005 8:59:23 AM   
  token

 

Posts: 1917
Score: 0
Joined: 1/14/2005
From:
Status: offline
heh.. you tried it without quotes and it didn't work ? I wonder why he had no problem without the quotes....hmmm

(in reply to Sir Suckalot)
 
 
Post #: 16
 
 Re: Set NTFS permissions - 4/7/2005 9:47:10 AM   
  Sir Suckalot

 

Posts: 25
Score: 0
Joined: 3/14/2005
From: Canada
Status: offline
Token and cjwallace: I can't get this to work with a variable. The first script works and the second doesn't. It seems to be the syntax.

'=========== First script ==============

Set shell = CreateObject("WScript.Shell")
shell.run "xcacls.vbs \\monnt2\users\JoeShmoe /I REMOVE /T /G CA\JoeShmoe:F /Q"

'============ Second Script ===============

Username = JoeShmoe
Set shell = CreateObject("WScript.Shell")
shell.run "xcacls.vbs \\monnt2\users\" &Username& " /I REMOVE /T /G CA\" &Username& ":F /Q"

Any ideas..?

(in reply to Sir Suckalot)
 
 
Post #: 17
 
 Re: Set NTFS permissions - 4/7/2005 10:55:58 AM   
  token

 

Posts: 1917
Score: 0
Joined: 1/14/2005
From:
Status: offline
Errors ?

Syntax seems to be alright to me.

(in reply to Sir Suckalot)
 
 
Post #: 18
 
 Re: Set NTFS permissions - 4/7/2005 12:44:28 PM   
  Sir Suckalot

 

Posts: 25
Score: 0
Joined: 3/14/2005
From: Canada
Status: offline
No error message, just one script that changes permissions and one that doesn't... I really don't get this one.

(in reply to Sir Suckalot)
 
 
Post #: 19
 
 Re: Set NTFS permissions - 4/7/2005 1:50:14 PM   
  token

 

Posts: 1917
Score: 0
Joined: 1/14/2005
From:
Status: offline
Replace:

Username = JoeShmoe

with:

Username = "JoeShmoe"

(in reply to Sir Suckalot)
 
 
Post #: 20
 
 
Page:   [1] 2 3   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 >> Set NTFS permissions Page: [1] 2 3   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