1.

Solve : closing program with alt+f4?

Answer»

I have one updating software which updates 5 programs.
But problem is because it stays opened when it is finished, I can close it with button close or with alt+F4.
If I use taskkill than it will close this updating software befor it finish updating but now alt+F4 I can press it before it finished updating and it will continue updating and when it is finished than it will accept alt+F4.
So how to use in batch file alt+F4?

I TRIED this vbs script but it does the same like taskkill it stops updating.

Code: [Select]Set WshShell = WScript.CreateObject("WScript.Shell")

' Start Notepad.exe
WshShell.Run "%windir%\notepad.exe"

' Select, or bring Focus to a window named `Notepad`
WshShell.AppActivate "Notepad"

' Wait for 4 seconds
WScript.Sleep 4000

WshShell.SendKeys "Foo"
WshShell.SendKeys "{ENTER}"
WshShell.SendKeys "BAR"
WshShell.SendKeys "{ENTER}"
WshShell.SendKeys "{CAPSLOCK}"
WshShell.SendKeys "baz"
WshShell.SendKeys "%{F4}"Sorry forget about this, it close updating software anyway when I press alt+F4 buttons.

Only if it is possible to use closing taskkill when button CLOSE appear?

Or if it is possible to close when it is Zero on CPE for about 10 seconds?

I tried this and not working, it close application no mather if CPU is 3%

Code: [Select]echo off

set "process_name=notepad.exe"

::remoce .exe SUFFIX if there is
set pn=%process_name:.exe=%

setlocal enableDelayedExpansion

set c=0
:: getting three snapshots of CPU usage of the given process
for /f skip^=2^ tokens^=3^ delims^=^" %%p in ('typeperf "\Process(%pn%)\%% Processor Time"  -sc 3') do (
    set /a counter=counter+1
    for /f "tokens=1,2 delims=." %%a in ("%%p") do set  "process_snapshot_!counter!=%%a%%b"

)

:: remove rem to see the cpu usage from the three snapshots
rem set process_snapshot_

:: if all three snapshots are less than 0000010 process will be killed
if 1%process_snapshot_1% LSS 10000010 if 1%process_snapshot_2% LSS 10000010 if 1%process_snapshot_3% LSS 10000010 (
     tskill %pn%
) Quote from: BLISK on October 29, 2014, 02:50:20 AM

I have one updating software which updates 5 programs.
But problem is because it stays opened when it is finished

This can be done with a single command probably.
Do you use a batch file to start this program?  Show us the code here so we don't have to guess what is being done.no, it is a update.exe file when I run it, it opens a window and update programs one by another at the end when It finishes it shows up button CLOSE. I run it over task scheduler and problem is because if that program is opened I can not run it again to update until I press CLOSE button on it. Quote from: Blisk on October 29, 2014, 10:23:12 AM
no, it is a update.exe file when I run it, it opens a window and update programs one by another at the end when It finishes it shows up button CLOSE. I run it over task scheduler and problem is because if that program is opened I can not run it again to update until I press CLOSE button on it.

It looks like it isn't a command line program, but a GUI program.

There isn't enough information about the task - I was assuming it was a command line program running from a batch file because you wanted to automate the closing of the window.

It helps to provide relevant details about the task in the first post, so that your readers can understand what it is that you are doing and how it operates.  Otherwise we have to use our crystal balls, and mine's at the mechanic for it's 6 month overhaul.yes, sorry I thought I explained good what program is. Yes it is gui and problem is updating again not working until first instance is closed.


Discussion

No Comment Found