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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Variable in path

Status
Not open for further replies.

wdmortl

Technical User
Oct 24, 2002
3
0
0
US
In VBS how would i declare a vaiable in the path of a copy statement? Thanks
 
Can you post an example of what you want to do ?
 
Set wn = WScript.CreateObject("WScript.Network")
Set fs = CreateObject("Scripting.FileSystemObject")
Set ws = CreateObject("WScript.Shell")

SystemRoot = ws.ExpandEnvironmentStrings ("%SYSTEMROOT%")

TxtFile = (SystemRoot & "\somefile.txt")
BakFile = (SystemRoot & "\somefile.bak")


fs.CopyFile TxtFile, BakFile

This script copies thr file %SYSTEMROOT%\somefile.txt (if windows was installed at c:\winnt then the this would be c:\winnt\somefile.txt) to %SYSTEMROOT%\somefile.bak

The Syntax for the copyfile method is fs.CopyFile Varible1, Varible2

The varibles need to be file paths or you will get an error.

Hope this helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top