AppActivate Function: ProcessID xxxx not found
Hi all,
I have created this sub to open a DOS-Box and enter a command, but the function AppActivate is giving me problems: it cannot find the ProcessID:
Public Sub Command1_Click()
Dim retPointerID As Integer
Dim SendKeys As String
retPointerID = Shell("c:\winnt\system32\cmd.exe")
System.Threading.Thread.Sleep(500)
AppActivate("retPointerID")
SendKeys = "mkdir abcde"
SendKeys = "{ENTER}"
'close dos window:
'SendKeys("Exit", True)
'SendKeys("{ENTER}", True)
End Sub
Now my questions are: (1) Can you use AppActivate to open up an DOS box and execute commands, or (2) can I bypass the ProcessID thing by using another function like Application.Start?
Apologies if I am unclear; I am quite new to VB and programming and have already figured out some things with the help of already posted messages in this forum but I cannot find an answer to tackle this one.
Basically what I am trying to create is an executable that opens a DOS-box, starts gzip to zip a data file, then start Secure FTP to put that file on a remote server...so I thought let's start simple and cover the basics first
Thanks very much in advance for your advice!
Re: AppActivate Function: ProcessID xxxx not found
Welcome to CG. I would use Console Applications to accomplish any task that needs to be done from the command prompt.
AppActivate function takes the ProcessID as a parameter and the processID should be integer. The parameter you are passing to it is a string with values as "ProcessID" and not the processID that was returned by Shell. So you should remove the quotes from AppActivate call. like this
Code:
AppActivate(retPointerID)
If you are new to VB then these samples from MS would be of great help. http://www.microsoft.com/downloads/d...displaylang=en
Quote:
(1) Can you use AppActivate to open up an DOS box and execute commands
You could, but then it would be better to use a console application rather than using old style of VB 6.0 coding. Take a look at the samples that are there in the above link.
Quote:
can I bypass the ProcessID thing by using another function like Application.Start?
As I said you could use Console Applications rather than Windows Forms application to achieve what you are trying to do.