Solved

How to tell if ntbackup is currently executing

Posted on 2003-10-30
10
720 Views
Last Modified: 2012-05-04
What are the parameters to use with FindWindow to tell if ntbackup is executing? I shell ntbackup from my application and need to know when it completes.
0
Comment
Question by:DJudd
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 3
10 Comments
 
LVL 16

Expert Comment

by:_nn_
ID: 9652535
I would use

  FindWindow("CMainBackupApp", NULL);

But, are you sure there isn't a better method ? What language are you using ?
0
 

Author Comment

by:DJudd
ID: 9652580
I was wanting to find a method, but just thought of this at first. Do you have a better idea?

I am using VB. For FindWindow() where do you find the "class" signatures to look for? For example, VB is ThunderForm, Word is OpusApp and Notepad is Notepad. You just gave me CMainBackupApp.

Thanks!
0
 

Author Comment

by:DJudd
ID: 9652613
I just tried this in VB and it didn't work. This is the code:

    Dim hWnd As Long
    Dim sClassName As String
    Dim sWindow As String

    sClassName = "CMainBackupApp" & Chr$(0)
    sWindow = Chr$(0)
    hWnd = FindWindow(sClassName, Null)
    If hWnd > 0 Then
      BringWindowToTop hWnd
    End If

Thanks!
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 16

Expert Comment

by:_nn_
ID: 9653248
There's a companion tool in Visual Studio called Spy++.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcug98/html/_asug_home_page.3a_.spy.2b2b.asp

I guess you must have it too. There's a search tool, drop it on a running instance of NtBackup. Then check the properties of that window, at the 'Class' tab, you'll find the classname.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcug98/html/_asug_searching_for_a_window.asp
0
 
LVL 22

Expert Comment

by:cookre
ID: 9653259
Never having been happy with window titles, I'd lean to shelling out a PSLIST and parsing its output.
0
 
LVL 16

Expert Comment

by:_nn_
ID: 9653303
I'm no VB coder : isn't there any way to shell and wait ?
or instead of shelling ntbackup directly, maybe try with something like "start /wait ntbackup <options>" ?
0
 

Author Comment

by:DJudd
ID: 9654125
I haven't tried the start /wait option above, but will research it.

I have used Spy minimally in the past, but not recently. I don't have any experience with PSList, but will research that.

I program in C, C++ (not much MFC) and C# too, so if you anyone has a solution, I can probably parse it to VB. I suppose I can try it. I think you just pass in 0 for NULL in VB, so I will try that too. The problem is that I need to get my shelled ntbackup process, not any other (although this is unlikely, I have to provide for this occurring).

Thanks for the responses so far, but I still don't have a solution to the original problem. If I find one (I usually do) I will post, and will keep checking this board for further responses.

Thanks!
0
 
LVL 16

Expert Comment

by:_nn_
ID: 9654194
This is C/C++ :

    HWND hWnd = FindWindow("CMainBackupApp", NULL);

It works on my W2K box with

  Microsoft Windows Backup
  Version 5.0
  © 1999 VERITAS Software Corporation. All rights reserved.

Possibly, you need to use another classname for another version. Using Spy++ (or any other similar tool) should give you that classname.
0
 
LVL 22

Expert Comment

by:cookre
ID: 9655279
nn:
The VB Shell() is asynchronous, but at least it returns the PID.  But then you have to use the regular API functions to check on the PID, so you might as well use CreateProcess() to begin with.

djudd: I meant to say TLIST instead of PSLIST (which is TSLIST on steroids)

TLIST is in the resource kit.
Sample output:
   0 System Process  
   8 System          
 144 SMSS.EXE        
 168 CSRSS.EXE      
 164 WINLOGON.EXE    
 216 SERVICES.EXE    
 228 LSASS.EXE      
 408 svchost.exe    
 444 spoolsv.exe    


PSLIST is from:
http://www.systeminternals.com/ntw2k/freeware/pslist.shtml
0
 
LVL 22

Accepted Solution

by:
cookre earned 250 total points
ID: 9655831
Just came across this VB bit from:
http://www.vb-helper.com/howto_shell_wait.html

that acts like a synchronous Shell():

' Start the indicated program and wait for it
' to finish, hiding while we wait.
Private Sub ShellAndWait(ByVal program_name As String, _
    ByVal window_style As VbAppWinStyle)
Dim process_id As Long
Dim process_handle As Long

    ' Start the program.
    On Error GoTo ShellError
    process_id = Shell(program_name, window_style)
    On Error GoTo 0

    ' Hide.
    Me.Visible = False
    DoEvents

    ' Wait for the program to finish.
    ' Get the process handle.
    process_handle = OpenProcess(SYNCHRONIZE, 0, process_id)
    If process_handle <> 0 Then
        WaitForSingleObject process_handle, INFINITE
        CloseHandle process_handle
    End If

    ' Reappear.
    Me.Visible = True
    Exit Sub

ShellError:
    MsgBox "Error starting task " & _
        txtProgram.Text & vbCrLf & _
        Err.Description, vbOKOnly Or vbExclamation, _
        "Error"
End Sub
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

737 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question