Geeks Talk

Prepare for your Next Interview




Close Command prompt using Vbscript

This is a discussion on Close Command prompt using Vbscript within the QTP forums, part of the Software Testing category; How to close the Command prompt using Vbscript Using batch file i am opening the any application by mentioning the path but that application is opening along with command prompt ...


Go Back   Geeks Talk > Software Testing > QTP

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 01-09-2008
Junior Member
 
Join Date: Dec 2007
Location: pune
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
pradeep.madishetti is on a distinguished road
Close Command prompt using Vbscript

How to close the Command prompt using Vbscript

Using batch file i am opening the any application by mentioning the path but that application is opening along with command prompt also showing. please let me know how to close the command prompt not an application
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 01-13-2008
Moderator
 
Join Date: Oct 2007
Location: Frankfort, KY
Posts: 283
Thanks: 3
Thanked 51 Times in 36 Posts
Anshoo_Arora is on a distinguished road
Re: Close Command prompt using Vbscript

Try this:

Sub cmdClose()
Dim oCMD
Set oCMD=GetObject("WSCript.shell")
oCMD.Close
Set oCMD=Nothing
End Sub
Reply With Quote
  #3 (permalink)  
Old 01-15-2008
Expert Member
 
Join Date: Jul 2007
Location: Kolkata
Posts: 110
Thanks: 6
Thanked 8 Times in 8 Posts
animesh.chatterjee is on a distinguished road
Re: Close Command prompt using Vbscript

hei it is not working in my machine...I have XP...
Reply With Quote
  #4 (permalink)  
Old 01-15-2008
Expert Member
 
Join Date: Jul 2007
Location: Kolkata
Posts: 110
Thanks: 6
Thanked 8 Times in 8 Posts
animesh.chatterjee is on a distinguished road
Re: Close Command prompt using Vbscript

it is giving a runtime error..
Reply With Quote
  #5 (permalink)  
Old 01-17-2008
Junior Member
 
Join Date: Sep 2007
Location: Bengaluru
Posts: 16
Thanks: 2
Thanked 1 Time in 1 Post
ravisuriya is on a distinguished road
Re: Close Command prompt using Vbscript

Friends,

This works for me on using it after writing the script for closing all the unwanted application. Let me know, for your testing it helps or not. I am waiting...



Set oShell = CreateObject("WScript.Shell")
Set oWmg = GetObject("winmgmts:")

strWndprs = "select * from Win32_Process where name='cmd.exe'"
Set objQResult = oWmg.Execquery(strWndprs)

For Each objProcess In objQResult

intReturn = objProcess.Terminate(1)

Next

Last edited by ravisuriya : 01-17-2008 at 02:06 AM.
Reply With Quote
The Following User Says Thank You to ravisuriya For This Useful Post:
  #6 (permalink)  
Old 01-18-2008
Expert Member
 
Join Date: Jul 2007
Location: Kolkata
Posts: 110
Thanks: 6
Thanked 8 Times in 8 Posts
animesh.chatterjee is on a distinguished road
Thumbs up Re: Close Command prompt using Vbscript

Nice work man...
GR8 work done...
Its working.....
Reply With Quote
Reply

  Geeks Talk > Software Testing > QTP


Thread Tools
Display Modes


Similar Threads

Thread Thread Starter Forum Replies Last Post
Start a TestSet via Command Prompt Geek_Guest QTP 0 10-22-2007 02:55 PM
I have 2 browsers open having the same title and I want to close the second browser? rkiran416 QTP 5 10-09-2007 06:25 AM
Invoke QTP script from command prompt Geek_Guest QTP 1 08-21-2007 06:00 AM
Pre-defined prompt and Report level prompt Geek_Guest Data Warehousing 1 07-03-2007 03:52 AM
Compile a C program using command prompt priyajos C and C++ 2 05-17-2007 08:52 AM


All times are GMT -4. The time now is 01:01 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Copyright © 2008 GeekInterview.com. All Rights Reserved