How to change a mouse cursor to a wait cursor (hourglass) in a command line application

I have a command line application that is called when a button is pressed in a seperate application (which cannot be modified). Since the command line application takes some time to run I would like to change the mouse cursor to a wait cursor (hourglass). I've tried:

Cursor.Current = Cursors.WaitCursor
 ' some method calls
Cursor.Current = Cursors.Default

I think this does not work because I have no control or form. Is there any way around this?

My code is:

    Function ResetLogin() As Boolean
        ' Purpose: Reset the login info
        Dim sUserName As String
        Dim sPassword As String
            deleteUserNameAndPassword(sUserName, sPassword)
            promptUserForUserNameAndPassword(sUserName, sPassword)
            Cursor.Current = Cursors.WaitCursor
            validateUserNameAndPassword(sUserName, sPassword)
        Catch ex As Exception
            MsgBox("Error: Could not start or login.  " & ex.Message, MsgBoxStyle.Exclamation + MsgBoxStyle.MsgBoxSetForeground, AppName)
            Return False
            Cursor.Current = Cursors.Default
        End Try

        MsgBox("Reset login information successfully.  ", MsgBoxStyle.Information + MsgBoxStyle.MsgBoxSetForeground, AppName)
        Return True
    End Function

If you need any other information please let me know.
Thanks in advance for your help.
Who is Participating?
Bob LearnedCommented:
You need a visible form in order to change the cursor from your application.  You might be able to use the SetCursor Windows API, but I haven't tested that theory.

this does not work
        System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor
so, try this:
        Me.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor
If none works, it is because cursor is inherited by forms of windows
I think that you should change the cursor where you have a button. You'll be able to determine the time required to load the other application in various ways depending on what the other application is.
Another idea is to declare a form and dispose it at the end:
Dim tempForm as New Form
Me.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor
andrewtingAuthor Commented:
Hi koouroshparsa,
I've tried all of your suggestions.
1. I am unable to do Me.Cursor.Current since my function is in a module and not in a class.
2. Unfortunately I can not change the cursor to where I have the button because that form is in a completely seperate application and my application can not 'talk' to it but only gets called by it.
3.  I've tried this as well and unfortunately this does not work.
andrewtingAuthor Commented:
Thanks Bob.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.