• 0

[VBscript] How to give focus to a window


Question

How can i give focus to a window? The thing is I am trying to do an unattended install of Ad-Aware and I'm running a VBscript to enter the installation password automatically.

Here the code

Set WshShell = WScript.CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")
On Error Resume Next
WshShell.run "%SystemRoot%\System32\cmd.exe"
WScript.Sleep 2000
WshShell.SendKeys "H:\Adaware.exe /S"
WshShell.SendKeys "~"

WScript.Sleep 8000
WshShell.SendKeys "123456"
WScript.Sleep 2000
WshShell.SendKeys "~"

WScript.Sleep 2000
WshShell.SendKeys "exit"
WshShell.SendKeys "~"

Wscript.Quit

As you can see I'm running the cmd prompt to run the adaware silent mode installation then I need to give focus to the password windows that pops up while installing and then I would like to give focus again to cmd prompt so it closes.

Any help is apreciated

note I erased my code just entered 123456

3 answers to this question

Recommended Posts

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.