How to tell if ntbackup is currently executing

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.
DJuddAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

_nn_Commented:
I would use

  FindWindow("CMainBackupApp", NULL);

But, are you sure there isn't a better method ? What language are you using ?
0
DJuddAuthor Commented:
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
DJuddAuthor Commented:
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
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

_nn_Commented:
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
cookreCommented:
Never having been happy with window titles, I'd lean to shelling out a PSLIST and parsing its output.
0
_nn_Commented:
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
DJuddAuthor Commented:
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
_nn_Commented:
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
cookreCommented:
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
cookreCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming

From novice to tech pro — start learning today.