Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vbs Script to check if a folder exist and then run a file

Hello I'm new here I need a script to check, if a folder exist and then run a file from the folder. If not, it should extract a ZIP file into a specific location. Thanks in advance!

like image 638
user1635949 Avatar asked Jan 02 '13 12:01

user1635949


People also ask

How do I get the current directory in VBScript?

You can use WScript. ScriptFullName which will return the full path of the executing script.

How do you create a file in VBScript?

Step 1: Press Ctrl + Shift + S on the keyboard, Or click File>Save As on the notepad window, this will open up a Save As dialog window asking where to save the current notepad document. Step 2: Now write any file name of your choice for this notepad document but make sure you write . vbs as its extension.

What is VB scripting language?

VBScript ("Microsoft Visual Basic Scripting Edition") is an Active Scripting language developed by Microsoft that is modeled on Visual Basic. It allows Microsoft Windows system administrators to generate powerful tools for managing computers with error handling, subroutines, and other advanced programming constructs.


1 Answers

'Objects
Set fso = CreateObject("Scripting.FileSystemObject")
Set shl = CreateObject("WScript.Shell")

path="C:\SomeFolderToExist\" 'path to folder    
exists = fso.FolderExists(path)

if (exists) then 
    program="myprog.exe" 'Program name to run
    shl.Run(path & program) 'Run a program
end if

For unzipping, I can only tell you to see this: Extract files from ZIP file with VBScript

like image 104
SmRndGuy Avatar answered Oct 02 '22 09:10

SmRndGuy