È possibile aggiungere un comando TAKEOWN .
Prova a usare l'esempio visto qui . Forse sono io ma il codice di esempio ha più senso di quello che .vbshai fornito.
Set WshShell = CreateObject("WScript.Shell")
strFile = "c:\test_folder\test_file.txt"
setPerms = "%COMSPEC% /c echo Y| C:\windows\system32\cacls.exe " & Chr(34) & strFile & Chr(34) & " /G domain\everyone:F"
wscript.echo setPerms
WshShell.run setPerms
Cambia la strFiledirectory e le domain\everyonetue preferenze.
Inoltre, sono propenso a pensare che il comando Cacls non sia eseguito con i privilegi di amministratore fino in fondo. Questo è lo .VBSscript che uso per elevare i comandi, i file, gli script, ecc ... e implica racchiudere il comando che si desidera eseguire come amministratore. Tenete presente che esegue anche in silenzio, ma è possibile disattivare questa opzione.
bElevate = False
if WScript.Arguments.Count > 0 Then If WScript.Arguments(WScript.Arguments.Count-1) <> "|" then bElevate = True
if bElevate Or WScript.Arguments.Count = 0 Then ElevateUAC
REM run the following script with admin privilages. start point.
ESEGUI QUESTO COMANDO COME AMMINISTRATORE
REM the above script will be run with admin privilages. end point.
Sub ElevateUAC
sParms = " |"
If WScript.Arguments.Count > 0 Then
For i = WScript.Arguments.Count-1 To 0 Step -1
sParms = " " & WScript.Arguments(i) & sParms
Next
End If
Set oShell = CreateObject("Shell.Application")
oShell.ShellExecute "wscript.exe", WScript.ScriptFullName & sParms, , "runas", 1
WScript.Quit
End Sub
runas. Quello che stai cercando di fare è un compito privilegiato.