473,405 Members | 2,338 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,405 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 10257
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.