1.

Solve : Giving ALT-F4 command in batch file?

Answer»

If I want to hit on ALT+F4 using a batch file, how would I go about by writing it in the batch file.

Is it even possible to do it in batch file

Please reply asap

ThanksWhat are you trying to do? Alt-F4 is used to kill a windows process. You would either have to write a script and use the sendkey method, or iterate the running processes and kill it that way. The problem here is that you need a way to direct the alt-f4 key code to the proper application.

Alt-F4 could be a BIT of a catch-22. If you use that key combo in an editor, the editor will shutdown! Not too cool.

Some but not all versions of Windows have the taskkill command, which could be hepful. What version are you using?

In a batch file, use the exit COMMMAND to shutdown the command window.

Happy computing... I am using Windows XP.

This is what I am trying to do.

I have created a batch file which installs a number of applications onto an end user's computer. The problem is that the first application installed by the user gets launched as SOON as the installation is finished. I dont want it to get launched. I can't change the way the installation is DONE because the first application was not packaged by me. I need it for my application to run.

The only way to kill the application and proceed with the rest of the installation process is pressing ALT-F4. I am trying to include this in the batch file but I don't know how to give the command so that ALT-F4 is pressed (functionality wise not literally) as soon as the installation is finished.

I hope I am clear in what I want to do.

If nothing works I might just include a pop-up window application that warns the user.
Thanks for all the help
If you are using XP Pro, I think you can use taskkill which will make it simple. If not this little script will do the job:

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


Change notepad.exe to your applicaton name. Save the file with a VBS extension and call it from your batch file. You cannot mix batch code and script code within the same file. Well you can, but it sure does create a mess when you run it.

Good luck.



Discussion

No Comment Found