I've put together a simple vbs to obtain the System Drive, and WindowsDirectory. What I'm not sure of now is how to pass the retrieved information into a flag for a command to run.
Here is what I have so far.
"On Error Resume Next
Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20
arrComputers = "."
For Each strComputer In arrComputers
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_OperatingSystem", "WQL", _
wbemFlagReturnImmediately + wbemFlagForwardOnly)
For Each objItem In colItems
WScript.Echo "SystemDrive: " & objItem.SystemDrive
WScript.Echo "WindowsDirectory: " & objItem.WindowsDirectory
Set wshShell = WScript.CreateObject ("WSCript.shell")
wshshell.run "cacls C:\Windows /E /C /G Users:R", 6, True
set wshshell = Nothing"
What I would like to do is replace the C:\Windows in the wshshell.run with the values returned from the SystemDrive & WindowsDirectory.
Any examples or a point in the right direction?