• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 535
  • Last Modified:

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
0
Joseph Daly
Asked:
Joseph Daly
  • 7
1 Solution
 
and235100Commented:
WScript.Sleep(1000)

(number in miliseconds)
0
 
and235100Commented:
i.e.

WScript.Sleep 30000
0
 
and235100Commented:
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"
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
Joseph DalyAuthor Commented:
Ok now what about the second part of the question. How do I launch the program using the switches with a VBS script?
0
 
and235100Commented:
What is the program?
Is it just an exe - or a com, bat - which?
0
 
and235100Commented:
Local exe:

Set objApp = CreateObject("WScript.Shell")
objApp.Run "cmd /C CD C:\ & Program Files & SomeFolder & SETUP"
0
 
and235100Commented:
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.
0
 
RobSampsonCommented:
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.
0
 
and235100Commented:
Hope that was helpful.
Thank you
0

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

  • 7
Tackle projects and never again get stuck behind a technical roadblock.
Join Now