I need to send an enter key to a remote computer. I would prefer not
having a vbscript on the remote if possible. I understand there are a
few ways of doing this so any and all suggestion are welcome. I am
running windows xp and need vbs code to sendkey ENTER to 50 computers
on a network.

I tried creating a file on the remote machine located at
"C:\Script\SendEnter.vbs" to try and run remotely because i understand
it is not possibly to sendkeys remotely but I cant seem to launch it.
I was also thinking about dynamically creating script and running it on
the the remote but I can't seem to get an application to run
interactively on a remote machine either.

this code works. On the remote machine, a "notepade.exe" process is
running but there is no visible notepad to interact with. So I was
unable to run a vbs file to send the Enter Key using this approach.

strComputer = "RmoteMachine"
Set objReg=GetObject( _
"winmgmts:{impersonationLevel=impersonate}!\\" & _
strComputer & "\root\CIMV2:Win32_Process")
result = objReg.Create ("notepad.exe", null, null,procID)

I have also tried the following which returns an activeX object error.

set oController = CreateObject("WSHController")
set oProcess = oController.CreateScript ("C:\Script\SendEnter.vbs",
strComputer)
oProcess.Execute
While oProcess.Status <> 2
WScript.Sleep 100
WEnd
WScript.Echo "Done"

All I would like to do is send an ENTER key to an active popup window
on a remote machine during a login.

Thanks for your assistance.

Re: sendkey ENTER to a remote computer by Suresh

Suresh
Thu Aug 10 16:10:47 CDT 2006

Try this (I don't have a remote machine to test this code on, but I
believe it could be made to work somehow. It works on my local computer
though.):

SendEnter.vbs (on remote computer)
------------------------------------------------------
Set objShell = CreateObject("WScript.Shell")
objshell.Sendkeys "{enter}"




Use this script on your local computer:
(adapted from
http://www.computerperformance.co.uk/vbscript/wmi_process_start.htm)

Dim objWMIService, objProcess
Dim strShell, objProgram, strComputer, strExe
strExe = "wscript.exe c:\SendEnter.vbs"

strComputer = "RemoteComputerName"

' Connect to WMI
set objWMIService = getobject("winmgmts://"_
& strComputer & "/root/cimv2")
' Obtain the Win32_Process class of object.
Set objProcess = objWMIService.Get("Win32_Process")
Set objProgram = objProcess.Methods_( _
"Create").InParameters.SpawnInstance_
objProgram.CommandLine = strExe

'Execute the program now at the command line.
Set strShell = objWMIService.ExecMethod( _
"Win32_Process", "Create", objProgram)




- Suresh

clu wrote:
> I need to send an enter key to a remote computer. I would prefer not
> having a vbscript on the remote if possible. I understand there are a
> few ways of doing this so any and all suggestion are welcome. I am
> running windows xp and need vbs code to sendkey ENTER to 50 computers
> on a network.
>
> I tried creating a file on the remote machine located at
> "C:\Script\SendEnter.vbs" to try and run remotely because i understand
> it is not possibly to sendkeys remotely but I cant seem to launch it.
> I was also thinking about dynamically creating script and running it on
> the the remote but I can't seem to get an application to run
> interactively on a remote machine either.
>
> this code works. On the remote machine, a "notepade.exe" process is
> running but there is no visible notepad to interact with. So I was
> unable to run a vbs file to send the Enter Key using this approach.
>
> strComputer = "RmoteMachine"
> Set objReg=GetObject( _
> "winmgmts:{impersonationLevel=impersonate}!\\" & _
> strComputer & "\root\CIMV2:Win32_Process")
> result = objReg.Create ("notepad.exe", null, null,procID)
>
> I have also tried the following which returns an activeX object error.
>
> set oController = CreateObject("WSHController")
> set oProcess = oController.CreateScript ("C:\Script\SendEnter.vbs",
> strComputer)
> oProcess.Execute
> While oProcess.Status <> 2
> WScript.Sleep 100
> WEnd
> WScript.Echo "Done"
>
> All I would like to do is send an ENTER key to an active popup window
> on a remote machine during a login.
>
> Thanks for your assistance.


Re: sendkey ENTER to a remote computer by clu

clu
Thu Aug 10 17:53:42 CDT 2006

Thank you for your reply.

I ran this code and it does in fact start a wscript.exe process on the
remote machine, however it fails to execute the script. I am testing
this by adding msgbox "ENTER" to the script, on the remote computer,
but the message is never displayed.


Re: sendkey ENTER to a remote computer by Suresh

Suresh
Thu Aug 10 18:33:59 CDT 2006


Seems it is not possible to run scripts interactively using the method
above. This is probably what will solve your problem:

http://www.windowsitpro.com/WindowsScripting/Article/ArticleID/38672/38672.html


clu wrote:
> Thank you for your reply.
>
> I ran this code and it does in fact start a wscript.exe process on the
> remote machine, however it fails to execute the script. I am testing
> this by adding msgbox "ENTER" to the script, on the remote computer,
> but the message is never displayed.