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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to excecute xcacls from vbs script? 2

Status
Not open for further replies.

confusedtekguy

IS-IT--Management
Jun 6, 2003
47
US
I need to create a script in vbs that opens xcacls on

\\server1\Resource kit
and run the following command on the command line

D:\users\%username% /G %username%:F /R everyone

Where %username% is the current username, and xcacls is ran off the server.
Is this possible? Thanks for your help!
 
You can try something like this:
Code:
cmd=Chr(34)&"\\server1\Resource kit\xcacls"&Chr(34)
arg="D:\users\%USERNAME% /G %USERNAME%:F /R everyone"
Set Sh=Wscript.CreateObject("Wscript.Shell")
ReturnCode=Sh.Run(cmd&" "&arg,1,True)



Hope This Help
PH.
 
That worked perfectly! One thing though... when I run the script, xcacl.exe comes up with the prompt "Do you wish to continue (Y/N)?" and I have to type in "y" for it to continue, is there a way to do that from the script?
 
Try this:
Code:
cmd=Chr(34)&"\\server1\Resource kit\xcacls"&Chr(34)
arg="D:\users\%USERNAME% /G %USERNAME%:F /R everyone"
Set Sh=Wscript.CreateObject("Wscript.Shell")
Sh.Run cmd&" "&arg,1,False
Sh.Sleep 1000
Sh.SendKeys "Y~"


Hope This Help
PH.
 
I ran that, but I'm getting an error on the Sh.Sleep line. When I comment it out, it runs but still get the same Y/N prompt.
 
Oh, the error is "Object doesn'T support this property or method: 'Sh.Sleep'"
 
Ok, I got it... I think:

cmd=Chr(34)&"\\smcd1\Resource kit\xcacls"&Chr(34)
arg="F:\users\%USERNAME% /G SMC\%USERNAME%:F administrators:F"
Set Sh = Wscript.CreateObject("Wscript.Shell")
Sh.Run cmd&" "&arg,1,False
Wscript.sleep 500
Sh.SendKeys "Y~"
Wscript.sleep 500
Sh.SendKeys "{ENTER}"
 
Ok, I got it... I think:

cmd=Chr(34)&"\\smcd1\Resource kit\xcacls"&Chr(34)
arg="F:\users\%USERNAME% /G SMC\%USERNAME%:F administrators:F"
Set Sh = Wscript.CreateObject("Wscript.Shell")
Sh.Run cmd&" "&arg,1,False
Wscript.sleep 500
Sh.SendKeys "Y~"
Wscript.sleep 500
Sh.SendKeys "{ENTER}"

Thanks for the help PHV
 
I'm sorry for the typo on the Sleep line. Glad you fixed it yourself.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top