Vbs脚本以检查文件夹是否存在然后运行文件

时间:2013-01-02 12:08:52

标签: vbscript filesystems

你好我是新来的我需要一个脚本来检查,如果存在一个文件夹,然后从该文件夹运行一个文件。如果没有,它应该将ZIP文件提取到特定位置。提前谢谢!

4 个答案:

答案 0 :(得分:16)

'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

要解压缩,我只能告诉您:Extract files from ZIP file with VBScript

答案 1 :(得分:2)

shl.Run (C:\SYSTEM TOOLS\HWMonitor.exe)替换为shl.Run (path & program)。您无需在那里指定路径和程序。

答案 2 :(得分:-1)

如果我正确理解: 创建脚本: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

运行scrip.sh:sudo ./script.sh

答案 3 :(得分:-1)

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