---
title: "vbs计划任务"
author: "ttitfly"
date: "2009-01-16T16:58:54Z"
tags: []
slug: "vbs"
draft: false
lastmod: "2009-01-16T17:06:38Z"
id: 317557
url: "https://ttitfly.iteye.com/blog/317557"
---

<span style="color:red">前提：F:/workspace/test目录下有My.exe依赖的配置</span>

1.如果test.vbs也在F:/workspace/test目录下
test.vbs文件内容如下：

```java
Dim Wsh 
Set Wsh = WScript.CreateObject("WScript.Shell") 
WScript.Sleep 5000 
Wsh.Run "F:/workspace/test/My.exe",,True 
WScript.quit
```


或者


```java
Dim Wsh 
Set Wsh = WScript.CreateObject("WScript.Shell") 
WScript.Sleep 5000 
Wsh.Run "My.exe",,True 
WScript.quit
```


<span style="color:red">计划任务里指向该test.vbs文件</span>

2.如果test.vbs不在F:/workspace/test目录下，则需要一个bat文件转（假如叫test.bat）

test.vbs文件内容如下(去执行bat)：

```java
Dim Wsh 
Set Wsh = WScript.CreateObject("WScript.Shell") 
WScript.Sleep 5000 
Wsh.Run "F:/workspace/test.bat",,True 
WScript.quit
```



test.bat:

```java
cd\
F:
cd F:\workspace\test
My.exe
```



<span style="color:red">计划任务里指向该test.vbs文件</span>