Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

System Folder Variable Question ...

Status
Not open for further replies.

MojoZig

Technical User
Sep 27, 2005
61
US
I have this script below and it works fine like this:
===========================
'Adds the HOSTS file
Const OverwriteExisting = TRUE

Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.CopyFile "\\server\updates\hosts", "c:\windows\system32\drivers\etc\", OverwriteExisting

'This copies the SDAT.exe file to C:\ and then installes it with a silent switch
objFSO.CopyFile "\\server\updates\sdat.exe" , "c:\", OverwriteExisting

set wshshell=createobject("wscript.shell")
wshshell.run "c:\sdat.exe -s",,true
set wshshell=Nothing
=================================

But when I try to use the %windir% or %systemroot% for the hosts file placement it won't work ... Anybody have suggestions? It errors with Line 5 Char 1 path not found.

I have tried:

objFSO.CopyFile "\\server\updates\hosts", "c:\%windir%\system32\drivers\etc\", OverwriteExisting

objFSO.CopyFile "\\server\updates\hosts", "c:\%systemroot%\system32\drivers\etc\", OverwriteExisting

I've tried it without the drive letter ....
objFSO.CopyFile "\\server\updates\hosts", "%systemroot%\system32\drivers\etc\", OverwriteExisting

Thanks in advance!

Tommy
 
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set WshShell = WScript.CreateObject("WScript.Shell")
objFSO.CopyFile "\\server\updates\hosts", WshShell.ExpandEnvironmentStrings("%systemroot%\system32\drivers\etc\"), OverwriteExisting

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
objFSO.CopyFile "\\server\updates\hosts", "c:\" & wshshell.ExpandEnvironmentStrings("%windir%") & "\system32\drivers\etc\", OverwriteExisting

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
Thanks! It works and I really appreciate your time! This site, and it's members, rocks!

Sincerely,
Tommy
Worldcrossings.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top