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

First time using VBS, need help

Status
Not open for further replies.

jack1529

Technical User
Jun 19, 2008
7
US
I have a few bat files that I want to convert into vbs. They basically are if then statemnets but I am not sure how to convert them. The first is...if not exist "C:\programfiles\..." copy "C:\programfiles\..." The others to are...if exist "C:\programfiles\..." del "C:\programfiles\..." . Can anyone help me?
 
'Variable declaration
Dim oFso

'Create a object FileSystem.
Set oFso = WScript.CreateObject("Scripting.FileSystemObject")

'Delete a file
If oFso.FileExists(File) then
oFso.DeleteFile(File)
end if

'Copy a file
if not oFso.FileExists(file)
oFso.CopyFile(File, destination)
end if

'unset var
set oFso = Nothing

Microsoft web page scripting documentation:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top