0

I followed a guide to create a batch file so I can delay a program from starting up for a few seconds. (I didn't want to use a 3rd party tool)

The thing is I don't want to see that cmd window for X seconds until it launches that program. Any ideas?

Here is the code I am using within the .bat file:

@ECHO OFF
TIMEOUT /t 3 > nul
START "" "C:\program.exe"

1 Answers1

0

This visual basic script does 3 things.

~ Grabs the current directory of where .VBS is stored and takes a file name.
~ Runs the given file w/ Admin privileges. (doesn't prompt for UAC)
~ Runs the file silently, without the CMD you mention.

bElevate = False
if WScript.Arguments.Count > 0 Then If WScript.Arguments(WScript.Arguments.Count-1) <> "|" then bElevate = True
if bElevate Or WScript.Arguments.Count = 0 Then ElevateUAC
REM run the following script with admin privilages. start point.

Set fso = CreateObject("Scripting.FileSystemObject")
GetTheParent = fso.GetParentFolderName(Wscript.ScriptFullName)

Set WshShell = WScript.CreateObject ("WScript.Shell")
WshShell.Run GetTheParent & ("\CUSTOMNAMEOFBAT.bat") 
WScript.Sleep 500

REM the above script will be run with admin privilages. end point.
Sub ElevateUAC
    sParms = " |"
    If WScript.Arguments.Count > 0 Then
            For i = WScript.Arguments.Count-1 To 0 Step -1
            sParms = " " & WScript.Arguments(i) & sParms
        Next
    End If
    Set oShell = CreateObject("Shell.Application")
    oShell.ShellExecute "wscript.exe", WScript.ScriptFullName & sParms, , "runas", 1
    WScript.Quit
End Sub

Copy/Paste the following code and save as .VBS. Put the .vbs script in the same directory as your .bat and change "CUSTOMNAMEOFBAT" (on end of line 11) to the name of your .bat.