Link to home
Start Free TrialLog in
Avatar of Joseph Daly
Joseph DalyFlag for United States of America

asked on

VBS file to wait certain amount of time then launch program (500pts)

I would like to know how to write a vbs file such that it can be run as a logon script. Once ran it will wait a given amount of time say 30 seconds while windows is loading and then launch the program with certain /switch1 /switch2 /switch3 parameters. Also if the script could be run either minimized or hidden that would be great.

The reason I need to do it this way is because the program I am running puts an icon down in the taskbar. If the script runs too early before windows is fully loaded there is no taskbar and therefore it doesnt work.

Thanks
Avatar of and235100
and235100
Flag of United Kingdom of Great Britain and Northern Ireland image

WScript.Sleep(1000)

(number in miliseconds)
i.e.

WScript.Sleep 30000
vbscripts will run by default hidden - i.e. during logon.

i.e. - with group policy:

gpedit.msc
User Config. \ Admin. Templates \ System \ Scripts
"Run Logon scripts visible"
You can set this to "Disabled"
Avatar of Joseph Daly

ASKER

Ok now what about the second part of the question. How do I launch the program using the switches with a VBS script?
What is the program?
Is it just an exe - or a com, bat - which?
ASKER CERTIFIED SOLUTION
Avatar of and235100
and235100
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Or:

Set objApp = CreateObject("WScript.Shell")
objApp.Run "cmd /C net use z: \\comp\path\ [password] & z: & setup"

for an setup.exe on a remote drive.
Or
strExe = "C:\Program Files\Microsoft Office\Excel.exe"
strParam1 = "C:\Temp\Test.xls"
strParam2 = "C:\Temp\Test2.xls"
Set objShell = CreateObject("WScript.Shell")
objShell.Run """" & strExe & """ """ & strParam1 & """ """ & strParam2 & """", 1, True


Regards,

Rob.
Hope that was helpful.
Thank you