Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Giving ALT-F4 command in batch file  (Read 24672 times)

0 Members and 1 Guest are viewing this topic.

Mahvish

  • Guest
Giving ALT-F4 command in batch file
« on: August 17, 2005, 08:15:22 AM »
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

Thanks

Sidewinder



    Guru

    Thanked: 139
  • Experience: Familiar
  • OS: Windows 10
Re: Giving ALT-F4 command in batch file
« Reply #1 on: August 17, 2005, 10:05:40 AM »
What 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.;D

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... 8)
The true sign of intelligence is not knowledge but imagination.

-- Albert Einstein

Mahvish

  • Guest
Re: Giving ALT-F4 command in batch file
« Reply #2 on: August 17, 2005, 11:40:23 AM »
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

Sidewinder



    Guru

    Thanked: 139
  • Experience: Familiar
  • OS: Windows 10
Re: Giving ALT-F4 command in batch file
« Reply #3 on: August 17, 2005, 01:26:10 PM »
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.;D

Good luck.
The true sign of intelligence is not knowledge but imagination.

-- Albert Einstein