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

XCACLS 1

Status
Not open for further replies.

sn0rg

IS-IT--Management
Joined
Aug 5, 2005
Messages
95
Location
GB
Chaps,

Using XCACLS in a script with a WMI command like this:

Code:
strCommand = "cmd /k xcacls \\server\drive$\folder /E /G User:RCXD"

Const HIDDEN_WINDOW = 12

Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")

Set objStartup = objWMIService.Get("Win32_ProcessStartup")
Set objConfig = objStartup.SpawnInstance_

objConfig.ShowWindow = HIDDEN_WINDOW
Set objProcess = objWMIService.Get("Win32_Process")
errReturn = objProcess.Create(strCommand, null, objConfig, intProcessID)

I want to get the STDOUT or STDERR from the XCALCS - how can I do this? I've looked at objshell.exec method, but it fires a visible window - I want to avoid that since I will be hitting thousands of users per run.
 
You could use the .Run method which will allow you to hide the command prompts. If you want to manipulate the output from the command you will need to pipe it to a temp file then read the file back in.

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
not very clean but how about redirecting output from cmd??? cmd ipconfig /all >> \\centralserver\%computername%.txt

one would hope that xcalcs would return its error to intReturn!!

alternatively you can scrap xcalcs and your manip using some other method, adssecurity.dll? ADSI for LDAP etc
 
Thanks guys, you've given me a couple of ideas to work on. Unfortunately I'm in a managed environment so adssecurity.dll isn't an immediate option.

I think I'll have to toy with output to temporary text files doing something like:

Create the file n.txt
Run XCACLS and direct output to it
Close it
Read it back in
Delete it
n = n + 1
Loop
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Sponsor

Back
Top