10

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!

Sae1962
  • 1,122
  • 15
  • 31
user1635949
  • 143
  • 1
  • 1
  • 3

3 Answers3

27
'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

Community
  • 1
  • 1
SmRndGuy
  • 1,719
  • 5
  • 30
  • 49
  • I tried this but it's not working Set fso = CreateObject("Scripting.FileSystemObject") Set shl = CreateObject("WScript.Shell") Path = "C:\SYSTEM TOOLS\" Exists = fso.FolderExists(Path) If (Exists) Then program = "HWMonitor.exe" shl.Run ("C:\SYSTEM TOOLS\HWMonitor.exe") End If – user1635949 Jan 06 '13 at 10:41
-2
Dim FILE, tmpfilepath, uniqueid As String
    uniqueid = Row.uniqueid
    tmpfilepath = "G:\Files\" + uniqueid
    If System.IO.Directory.Exists(tmpfilepath) Then
          do something
              Else
        System.IO.Directory.CreateDirectory(tmpfilepath)


    End If
Dan
  • 17
  • 2
-4

If I understand correctly : create a script: sudo vim script.sh

#!/bin/bash
    echo "enter your path"
    read path

    if [[ -d "$path"  ]]
            then
            echo $(sudo $path/yourprograme)
            else
            echo "enter your specific location"
            read spec
            $ mkdir -p $spec
            $ unzip yourfiles.zip -d $spec

            fi

run the scrip.sh : sudo ./script.sh