vbscript - how to get permission to replace the utilman.exe -


i permission replace or rename utilman.exe. script below not working.

dim strfolder, struser, strdomain strfolder = "c:\windows\system32\utilman.exe" set fso = createobject("scripting.filesystemobject") set objshell = wscript.createobject("wscript.shell") objshell.run("takeown /a /f" & chr(34) & strfolder & chr(34)),1,true objshell.run("icacls chr(34) & strfodler &  chr(34) /grant administrator:f"),1,true wscript.quit 

you defined icacls commandline single string when apparently want contain value of variable strfolder in double quotes. must use string concatenation work in vbscript. also, may want put space after parameter /f of takeown , remove parentheses around commands.

change this:

objshell.run("takeown /a /f" & chr(34) & strfolder & chr(34)),1,true objshell.run("icacls chr(34) & strfodler &  chr(34) /grant administrator:f"),1,true 

into this:

objshell.run "takeown /a /f " & chr(34) & strfolder & chr(34), 1, true objshell.run "icacls " & chr(34) & strfolder &  chr(34) & " /grant administrator:f", 1, true 

Comments

Popular posts from this blog

php - Admin SDK -- get information about the group -

Python Error - TypeError: input expected at most 1 arguments, got 3 -

dns - How To Use Custom Nameserver On Free Cloudflare? -