Monday, May 21, 2012

Check file exist

Here is how to check for file exist while we copy to or from machine’s data
Example below show the checking of CMD.exe in Windows\system32 folder

'Set Object
Set fso = CreateObject("Scripting.FileSystemObject")

'Create Condition
If (fso.FileExists("C:\windows\system32\cmd.exe")) Then
'Alert User
WScript.Echo("File exists!")
WScript.Quit()
Else
'Alert User
WScript.Echo("File does not exist!")
End If

'Exit Script
WScript.Quit()

0 comments:

Post a Comment