Vbs脚本检查文件夹是否存在并运行文件

10

大家好,我是新来的。我需要一个脚本来检查文件夹是否存在,如果存在则运行文件夹中的文件。如果不存在,则应将ZIP文件解压到特定位置。提前感谢!


5
在SO上,"Gimme da codez"这样的问题是不受欢迎的。请提供更具体的问题和详细信息。 - Eugene Mayevski 'Callback
3个回答

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

对于解压缩,我只能告诉您查看此链接:使用VBScript从ZIP文件中提取文件


我尝试了这个,但它没有起作用。Set fso = CreateObject("Scripting.FileSystemObject") Set shl = CreateObject("WScript.Shell")Path = "C:\SYSTEM TOOLS" Exists = fso.FolderExists(Path)如果(存在)则 program = "HWMonitor.exe" shl.Run ("C:\SYSTEM TOOLS\HWMonitor.exe") 结束 如果 - user1635949

-3
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

1
这个有什么不同/更好的地方,与已经发布的几个答案相比? - mjuarez
1
这不是VBScript。 - jscarle

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

2
这不是VBScript。 - jscarle

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接