CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2005
    Posts
    1

    Question 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!
    Last edited by Rich69; October 12th, 2005 at 09:03 AM.

  2. #2
    Join Date
    Jun 2004
    Location
    Kashmir, India
    Posts
    6,808

    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
    (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.
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured