How to Use .Dll in VBS
A DLL file is a dynamic link library that contains programming processes that are available for use by other programs. The ability to call a subroutine in a DLL file from Visual Basic Script (VBS) greatly expands the capabilities of VBS.
Instructions
-
-
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.
-
1
Tips & Warnings
You can access Microsoft-, third-party- and custom-developed DLL files using this technique.
References
Resources
- Photo Credit code image by charles taylor from Fotolia.com