Friday, April 4, 2008

Run application without User intervention

Suppose you want to run hyperterminal via command mode without user intervention.

The following vbs script is very useful for you..


' openhyper.vbs
' Example VBScript Run Notepad and use SendKeys
' -----------------------------------------------------'
' Developed by S.Murugan
Option Explicit
Dim objShell, Racey, intCount
Set objShell = CreateObject("WScript.Shell")
objShell.Run "hypertrm new.ht"
Wscript.Sleep 1500
Racey = 1000
intCount=0

objShell.SendKeys "%T"
WScript.Sleep 1500
objShell.SendKeys "C"
WScript.Sleep 1500
objShell.SendKeys "{TAB}"
WScript.Sleep 1500
objShell.SendKeys "{TAB}"
WScript.Sleep 1500
objShell.SendKeys "{ENTER}"

WScript.Quit
' End of Example SendKeys VBScript




Updated file

' hyperopen.vbs
' Example VBScript Run Notepad and use SendKeys
' -----------------------------------------------------'
Option Explicit
Dim objShell, Racey, intCount
Set objShell = CreateObject("WScript.Shell")
objShell.Run "hypertrm new.ht"
Wscript.Sleep 1500
Racey = 1000
intCount=0

objShell.SendKeys "%T"
WScript.Sleep 1500
objShell.SendKeys "C"
WScript.Sleep 1500
objShell.SendKeys "C:\Documents and Settings\murugans\Desktop\capture.txt"
WScript.Sleep 1500
objShell.SendKeys "{TAB}"
WScript.Sleep 1500
objShell.SendKeys "{TAB}"
WScript.Sleep 1500
objShell.SendKeys "{ENTER}"

WScript.Quit
' End of Example SendKeys VBScript




' stop the application new
' Example VBScript Run Notepad and use SendKeys
' -----------------------------------------------------'
Dim objshell
Set objShell = CreateObject("WScript.Shell")
While objShell.AppActivate("new") <> True
WScript.Sleep 500
Wend
WScript.Sleep 100
objShell.SendKeys "{ENTER}"

objShell.SendKeys "%F"
WScript.Sleep 1500
objShell.SendKeys "x"
WScript.Sleep 1500
objShell.SendKeys "{ENTER}"

WScript.Quit
' End of Example SendKeys VBScript

No comments: