473,236 Members | 1,592 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,236 software developers and data experts.

AppActivate applied to cmd.exe

Hello Community,

I have a question : why , if I try to use AppActivate applied to cmd.exe it doesn't work?

My purpose is to run a VB script from Excel which opens a Telnet or an ftp session, then it gives commands using SendKeys method. I am using the following code:
'---------------------------------------------------------------
Dim p_ID

Dim FullPath As String

FullPath = "C:\WINDOWS\system32\cmd.exe"

p_ID = Shell(FullPath, 1)

AppActivate p_ID
Application.SendKeys "ABCDE", True
'---------------------------------------------------------------


Note that :
1.If I call a different program (e.g.: FullPath = "C:\WINDOWS\notepad.exe")
everything works.

2.If I use an object "WScript.Shell" I can apply object.Run "ftp....." , but login
fails.

3. If at first I open cmd.exe using : object.Run "cmd" and then I use:
Application.SendKeys "ABCDE", True it doesn't work very much.

Who has an idea? Thanks

diSangro
Jan 8 '07 #1
5 10245
Killer42
8,435 Expert 8TB
I'm confused. I have seen AppActivate ID mentioned in a couple of messages recently. But I thought AppActivate expected a window title, not an ID. Everything I can see in both VB6 and Excel's VBA editor appears to support this.
Jan 9 '07 #2
You can use either the window title , or the task ID returned by the function Shell , this is written in the VB help guide.


I'm confused. I have seen AppActivate ID mentioned in a couple of messages recently. But I thought AppActivate expected a window title, not an ID. Everything I can see in both VB6 and Excel's VBA editor appears to support this.
Jan 9 '07 #3
Killer42
8,435 Expert 8TB
You can use either the window title , or the task ID returned by the function Shell , this is written in the VB help guide.
Fair enough.

(I'm currently on a PC which doesn't have VB help available, or I'd have checked.)
Jan 9 '07 #4
Ehy Killa!

I think I got a way to solve this problem, I should use:

sh.Exec "%COMSPEC% /k.....<whatever characters or commands>"

where sh is WShell object
but now I don't have time to try it.

What do you think?



Fair enough.

(I'm currently on a PC which doesn't have VB help available, or I'd have checked.)
Jan 9 '07 #5
Killer42
8,435 Expert 8TB
Ehy Killa!

I think I got a way to solve this problem, I should use:
sh.Exec "%COMSPEC% /k.....<whatever characters or commands>"
where sh is WShell object
but now I don't have time to try it.
What do you think?
It looks worth a try. Can you include an environment variable like that? If not, perhaps you can concatenate Environ$("COMSPEC") into the string, or something.

Also, if you can get it to use the START command, then you don't need to know what application to run. Just start the data file, and Windows will work out what application to use.
Jan 9 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Alex | last post by:
Can I find a Function like AppActivate of VB.net in C#?
1
by: Lars Gaarde | last post by:
I need to activate another application, after clicking in a right click menu/context menu in my application. Problem is that the other application doesn't get activated and brought to the front...
0
by: Austin | last post by:
Hello: I have written a very simple vb program (using the new .net interface). I have a website to which I must upload many files. The filenames are incremented in such a way that a simple...
1
by: scottt | last post by:
Hello All, I am trying to use SendKeys to send some keystrokes to another application. I am using the VB Runtime reference to use the following line in my C# program: ...
1
by: André | last post by:
Hi, c# .net 2005 I have a windows Sendkeys program using webBrowser1 VS.net 2005. I have to click a client side message box to say {enter}. How do I set focus back to the windows form for...
0
by: natty2006 | last post by:
Submission Deadline extended: 13 November 2006 ************************************************************* IADIS INTERNATIONAL CONFERENCE APPLIED COMPUTING 2007 February 17-20, 2007 -...
2
by: =?Utf-8?B?bXIgcGVhbnV0?= | last post by:
I want to activate an application (Excel) in code. If I reference microsoft.visualbasic, I could use: Interaction.AppActivate("Microsoft Excel"); But I wold rather use a native C# approach. I...
0
by: tutorialwebs | last post by:
Applied cryptography text books http://www.365x24live.com/Applied%20Cryptography/ewtoc.html http://www.365x24live.com/Applied%20Cryptography/ewtoc.html...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.