I'm trying to do something simple and after failing miserably for the last 2 hours have decided to ask for help.
All I need to do is set everyone = full control on a remote computer, for a folder in Program Files. I'm trying to use cacls to do this. If I run the command in a cmd window, it works. The wscript.echo setPerms at the end of the script is showing the correct command.
Any hints welcomed!
----
strComputer = InputBox("Enter the remote computer name:", "Input required")
Set objShell = CreateObject("Wscript.Shell")
If strComputer = False then
'user clicked the cancel button, exit the script
wscript.quit
End If
' end the script if the computer does not ping
Set WshShell = CreateObject("WScript.Shell")
PINGFlag = Not CBool(WshShell.run("ping -w 500 -n 1 " & strComputer,0,True))
If PINGFlag = False Then
MsgBox strComputer & ": Host was not reachable.", vbexclamation, "Connect failed"
wscript.quit
End If
strDest = "\\" & strComputer & "\c$\Program Files\vbscript test\"
setPerms = "%COMSPEC% /c echo Y| C:\windows\system32\cacls.exe " & Chr(34) & strDest & Chr(34) & " /G domain\everyone:F"
wscript.echo setPerms
WshShell.run setPerms