2

I need a command to replace the hosts file on my machine. Seems pretty straight forward but I cannot get the command to work with xcopy. Any obvious flaws in the command?

luaexec -w -f "XCOPY" "%ScriptPath%/ModifiedHosts/vista/hosts" "%windir%/system32/drivers/etc/hosts" /H

The /R flag does not seem to help and the error I get is "Error: ShellExecuteEx failed 0x2" if I remove all quotes but the beginning and end quotes

Oddthinking
  • 24,359
  • 19
  • 83
  • 121
Joe
  • 409
  • 2
  • 9
  • 19

3 Answers3

1

Did you get any error?

Try this:

luaexec -w -f "XCOPY %ScriptPath%/ModifiedHosts/vista/hosts %windir%/system32/drivers/etc/hosts" /H

Also, you can try robocopy.

FerranB
  • 35,683
  • 18
  • 66
  • 85
0

is the hosts file write protected? it probably is.. add a /R to your commandline

Scott Evernden
  • 39,136
  • 15
  • 78
  • 84
0

On Vista, you need to run as Administrator to change the hosts file.

Reference

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
Oddthinking
  • 24,359
  • 19
  • 83
  • 121