Skip to content

Instantly share code, notes, and snippets.

@keejelo
Created November 25, 2021 16:02
Show Gist options
  • Select an option

  • Save keejelo/52ba7b8a02afa10d95c07ae41e07b48c to your computer and use it in GitHub Desktop.

Select an option

Save keejelo/52ba7b8a02afa10d95c07ae41e07b48c to your computer and use it in GitHub Desktop.
Waits n seconds before running something
'--------------------------------------------------------------------------------
' 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