VBS运行文件夹中的所有VBS文件 [英] VBS to run all VBS files in folder

查看:126
本文介绍了VBS运行文件夹中的所有VBS文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是vb脚本的新手,所以这很容易做到.

我正在寻找一个脚本,它将运行指定文件夹中的所有程序,包括VBS,exe,bat文件.

我想将文件放在文件夹中并运行此VBS,然后将运行所有文件.

它还需要等待每个完成,然后再移动到下一个文件.

越基础越好.

I am new to vb-scripting so this may be easy to do.

I am looking to make a script that will run all programs including VBS, exe, bat files in a specified folder.

I want to put the files in the folder and run this VBS that will then run all of the files.

It also needs to wait for each to finish before moving to the next file.

The more basic the better.

推荐答案

Dim myFolder : myFolder = "c:\temp"

Set fso = CreateObject("Scripting.FileSystemObject")
Set sh = CreateObject("WScript.Shell")

For Each file In fso.GetFolder(myFolder).Files
    If Len(file.Name) > 5 Then
        Dim extension : extension = UCase(Right(file.Name, 3))
        Select Case extension
        Case "VBS":
            sh.Run "wscript """ & file.Path & """", 1, True
        Case "EXE":
        Case "BAT":
            sh.Run file.Path, 1, True
        End Select
    End If
Next


这篇关于VBS运行文件夹中的所有VBS文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆