0

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 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.