Lets first of all record a simple test and then we will run this test through a automated script.
1. Open QTP and a new blank test.
2. Click on Record. Record and Run Settings window will open. GO to Windows Applications tab and choose the first option "Record and run test on any open Windows-based application". Click Ok.
3. Go to Start-> All Programs-> QuickTest Professional->Sample Application-> Flight.
4. Login window opens.
5. Enter "sach" as Agent Name and "mercury" as Password. Click Ok.
6. Flight Reservation window opens. Go to File->Exit.
7. Save the Test. (I saved the test as Test3 at C:\Program Files\Mercury Interactive\QuickTest Professional\Tests\Test3)
Write the below code in a notepad, save it with .vbs extention and run it from command prompt.