Solved

How to tell if ntbackup is currently executing

Posted on 2003-10-30
10
716 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
  • 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
 
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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
EvenOdd challenge 10 83
Excel object stays open 19 65
word0 challenge 4 52
index Out OF Range Exception error 4 28
This article will show, step by step, how to integrate R code into a R Sweave document
Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
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…

707 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now