Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

WshShell.AppActivate & Wscript.Arguments

823 views
Skip to first unread message

Helmut Baum

unread,
Aug 17, 2001, 2:11:10 AM8/17/01
to
Hello Newsgroup,
I have got the following Problem.
I try to give over an argument to a VBS like in the
example below. I start the "test.cmd", it gives the "pid"
over to "activate_windows.vbs". Now the argument is stored
in "pid" again and the line "WshShell.AppActivate (pid)"
should active the window with the process ID 400. But it
doesn't work.
When I store the pid in the VBS. Like this "pid = 400", it
works, fine.
The argument is stored correctly. I tryed it !!!

Have you got any suggestions where my problem is?

Best regards,
Helmut Baum

"test.cmd":
--------------------------
setlocal

set pid=400

call activate_windows.vbs %pid%

endlocal
--------------------------

"activate_windows.vbs":
--------------------------
set wshshell = CreateObject("WScript.Shell")
set args = Wscript.Arguments
pid = args(0)
username = "tesuser"
password = "pw"
hoststring = "@test.host.com"

WshShell.AppActivate (pid)

wshshell.SendKeys(pid & "~")
wshshell.SendKeys(username & "~")
wshshell.SendKeys(password & "~")
wshshell.SendKeys(hoststring & "~")
--------------------------

Torgeir Bakken

unread,
Aug 17, 2001, 3:03:29 PM8/17/01
to
Hi

The args returns a string, but AppActivate wantd integer

pid = args(0) 'string

pid = 400 'integer

pid = CInt(args(0)) ' integer

You can use MsgBox TypeName (pid) to verify this.

Regards,
Torgeir

Helmut Baum

unread,
Aug 20, 2001, 1:49:44 AM8/20/01
to
Thank you very much, Torgeir. It works !!!
Have you got a book tip for me, where these tip are in?

Regards
Helmut

>.
>

Torgeir Bakken

unread,
Aug 20, 2001, 11:19:18 AM8/20/01
to
Hi,

I don't think you will find this tip in a book, but here is a couple of
books that I like:


Title: Windows Scripting Secrets
Author: Tobias Weltner
Publisher: Hungry Minds, Inc.
ISBN: 0764546848

Title: Vbscript in a Nutshell : A Desktop Quick Reference
Author: Paul Lomax, Matt Childs, Ron Petrusha
Publisher: O'Reilly & Associates
ISBN: 1565927206


Torgeir

0 new messages