Created
November 25, 2021 16:02
-
-
Save keejelo/52ba7b8a02afa10d95c07ae41e07b48c to your computer and use it in GitHub Desktop.
Waits n seconds before running something
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| '-------------------------------------------------------------------------------- | |
| ' Filename: wait.vbs | |
| '-------------------------------------------------------------------------------- | |
| ' Wait v1.0 - Waits n seconds before running something | |
| ' Author: Keejelo | |
| ' gist.github.com/keejelo/52ba7b8a02afa10d95c07ae41e07b48c | |
| '-------------------------------------------------------------------------------- | |
| ' Usage: wait "arg1" [arg2] | |
| ' @arg1 = "processname", e.g. "notepad.exe" | |
| ' @arg2 = seconds to wait until process is started | |
| ' Example: wait "notepad.exe" 10 | |
| '-------------------------------------------------------------------------------- | |
| Option Explicit | |
| If WScript.Arguments.Count = 0 Then | |
| WScript.Echo "ERROR: missing argument!" & vbCrlf & vbCrlf & _ | |
| "Usage: wait ""arg1"" [arg2]" & vbCrlf & vbCrlf & _ | |
| "@arg1 = ""processname"", e.g. ""notepad.exe""" & vbCrlf & vbCrlf & _ | |
| "@arg2 = seconds to wait until process is started" & vbCrlf & vbCrlf & _ | |
| "Example: wait ""notepad.exe"" 10" | |
| Else | |
| If WScript.Arguments.Count = 2 Then | |
| WScript.Sleep( WScript.Arguments.Item(1) * 1000 ) | |
| End If | |
| Dim objShell | |
| Set objShell = WScript.CreateObject("WScript.Shell") | |
| objShell.Run( WScript.Arguments.Item(0) ) | |
| Set objShell = Nothing | |
| End If | |
| WScript.Quit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment