- 1). Create a text file on your desktop and rename the file "AutoExist.vbs". It is important to name the file with the extension "vbs" as this is how Windows knows to run the file as a VB script.
- 2). Right-click the icon of the new file and select "Edit." Windows should open the file as an empty file in notepad. It may use a different editor, if one has been installed, but by default VBS files are edited with notepad.
- 3). Put this code in the file:
dim fso, file
Set fso = CreateObject("Scripting.FileSystemObject") ' Load the FileSystemObject
' from within the scripting dll
file = "c:\autoexec.bat"
if fso.fileexists(file) then ' Call a method of the object that resides in the dll
MsgBox("AutoExec.bat Exists")
end if - 4). Save the file. You can keep notepad open to change the script as needed.
- 5). Double click the "AutoExist.vbs" file and windows will execute the script. If the file "c:\autoexec.bat" exists a message box will pop up, if the file doesn't exist nothing will happen.
SHARE