1.

Solve : Closing by Batch FIle?

Answer»

[size=16]Is there any command for a batch filethrough which i can close a program or WINDOW?[/size]

A couple of possibilities. TaskKill is installed with some versions of Windows. If you want to close the command window where the batch file is running, use the exit command. Otherwise you need to write a Windows Script.

Code: [Select]
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colProcessList = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = 'Notepad.exe'")

For Each objProcess in colProcessList
objProcess.Terminate()
Next


Save the script with a VBS extension and change notepad.exe accordingly.

Hope this helps. Thanks
But after saving the above script as script.vbs

when I double Clicked it I got the following message:

script: C:\Windows\Desktop\script.vbs
Line Number: 2 Column: 0
Category: Microsoft VBScript Runtime Error
Description: File name or class name not found during Automation operation: 'GetObject'[/color]

Note: I have Win98 SE

[/font]Very pretty Shouvik but totally unnecessaryIt may also help people ,if they new what animal they are dealing with......like win95 etc.........pascal/borland etc.This seems to be the most POPULAR QUESTION this week. If the script didn't work (probably an old version of the script INTERPRETER or non-existant COM OBJECTS) check to see if you have a version of tskill.
If you do check out your options with tskill /?. If not you may just have to use the task manager.



Discussion

No Comment Found