0
votes

I want to change the permissions of etc/host file.

i am running this vbs script

Dim objShell
Set objShell = WScript.CreateObject ("WScript.shell")
objShell.run "cmd cacls C:\Windows\System32\drivers\etc /e /p everyone:f  "
Set objShell = Nothing

now the problem is that whenever i run this i get access denied. Yes, i am administrator. but when i manually click the file and go to security settings and change permission, it prompt for domain admin name and password and when i enter it it works.

but with command line , how can i enable domain user name and password so that access is not denied. I want to integrate this in vbs script.

I hope i am clear and thank you

1

1 Answers

1
votes

Looks like you have UAC enabled, so try running the command via ShellExecute with the "runas" verb set:

cmd  = "cacls.exe"
args = "C:\Windows\System32\drivers\etc /e /p everyone:f"

Set app = CreateObject("Shell.Application")
app.ShellExecute cmd, args, "", "runas", 0

However, I'd recommend using icacls rather than cacls. Also, granting everyone full control to the etc directory is a BAD IDEA. Don't actually do this.