Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Batch File or similar to automate task? 1

Status
Not open for further replies.

jdunderhill

Technical User
Nov 25, 2002
223
GB
Hi there

I am trying to create a batch file that will load an exe and then simulate the click of the ok button on the window that pops up after you launch that exe

Basically the exe is a fix for Mail recipient in office 97 and simply is a program that applies the fix but asks you to select ok before it is applied

I wanted to automate the ok part so it is completely automatic when I log on e.g the batch file will launch the exe and then ok the window that comes up

Just wondered if anyone has any suggestions if this is possible to do?

Cheers

Jamie
 
You can use VBScript to do this. You would need a script that did something like the following:

Code:
set WshShell = CreateObject("WScript.Shell")

'Launch Application from the command line and wait for 2 seconds
WshShell.Run "application.exe"
WScript.Sleep 2000

'Wait until the application has loaded - Check every second
While WshShell.AppActivate("Application Name") = FALSE
wscript.sleep 1000
Wend

'Bring the application to the foreground
WshShell.AppActivate "Application"
WScript.Sleep 500

'Send keys to move to Ok button
WshShell.SendKeys "{TAB}"
WScript.Sleep 501

'Send Enter key to Click Ok Button
WshShell.Sendkeys "{ENTER}"
Wscript.Sleep 505

You would obviously need to modify the script to include the application EXE name and also the proper application name as shown on the taskbar.

--------------------------------------
"Insert funny comment in here!"
--------------------------------------
 
Hi, thanks for taking the time to help me out

It was just what I was looking for, I managed to tailor it and it worked a treat. Have awarded you a star :)

Regards

Jamie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top