topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Thursday March 28, 2024, 7:17 am
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Last post Author Topic: DONE: Program to Start another program, and then shut down after xx:xx time.  (Read 23401 times)

nkormanik

  • Participant
  • Joined in 2010
  • *
  • Posts: 552
    • View Profile
    • Donate to Member
Here is the idea:

Defaults held in an .ini file.  All set and ready to go.  Desktop shortcut.

New Program will start any program, PGM, user wants (program executable location held in .ini file).

After a certain amount of time (xx:xx, held in .ini file) the New Program will terminate PGM, and exit completely leaving zero memory footprint.

The chief purpose of this New Program is at the termination end -- stopping PGM after a certain amount of time.  If there is already an existing way to accomplish this, please let me know.

Anyone interested??

Thanks much.

Nicholas Kormanik



MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,736
    • View Profile
    • Donate to Member
The trouble with a general-purpose program termination routine is knowing particulars of the program to be terminated.  For example, if the target program is an editor, how to make it save febore killing it. If it's writing to the drive, how to detect it and wait until it's done etc...

A pop-up reminder saying "Don't you want to terminate App xyz??" may be simpler.

nkormanik

  • Participant
  • Joined in 2010
  • *
  • Posts: 552
    • View Profile
    • Donate to Member
Good point, MilesAhead.  In this particular case let's assume no problem terminating.  Nothing to save.  No disk writes to complete.

Just kill it.  After xx:xx time.

Researching out there, others have asked for such a program, and apparently none exists.


x16wda

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 888
  • what am I doing in this handbasket?
    • View Profile
    • Read more about this member.
    • Donate to Member
With some restrictions this batch file should do it:

   start notepad.exe
   ping -n 61 127.0.0.1>nul
   pskill notepad.exe

This will fire up Notepad and then kill it a minute later.  The restrictions would be that you have to convert your desired run time to seconds (and add one), and in the end it kills all copies of the program.  In real use you'd use something like min.exe to minimize the cmd window (or something like chp.exe to hide it), you'd set the executable and time limit as parameters to pass, you could use one of several utilities to convert time to duration in seconds, and you might use one of Horst Schaeffer's utilities to let you choose the program to run, etc.  Tart it up real nice.  :D

A plain old batch file isn't as pretty as a nice exe, but if you don't need the efficiency of compiled code it can do fine.
vi vi vi - editor of the beast

x16wda

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 888
  • what am I doing in this handbasket?
    • View Profile
    • Read more about this member.
    • Donate to Member
You know, a tiny little command line program that would spit out either its own pid or its parent's pid would be real convenient for this (and for some other tasks I've needed to do)...
vi vi vi - editor of the beast

c.gingerich

  • Supporting Member
  • Joined in 2011
  • **
  • Posts: 748
    • View Profile
    • The Blind House
    • Donate to Member
Here is a quick command-line app I made (can also use an ini file. See ReadMe.txt). If it works for you I'll make an official app.

How to use: RunAndKill.exe "<Full path to exe>" <Killtime>

Killtime must be in HH:MM:SS format.

See the ReadMe.txt file for more info.

app103

  • That scary taskbar girl
  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 5,884
    • View Profile
    • Donate to Member
Well, there is also my Lacuna Launcher, which can run a list of apps, and pause between items in the list. If you were to set it up to run the desired app, with the pause time between app launches to be how long you want the app open before being closed, then ran an app like Movie-ize as the next app to launch in the list, and set that to kill the previous app. It could serve the desired purpose. You'd have to create a separate Lacuna Launcher list for each app, though.

nkormanik

  • Participant
  • Joined in 2010
  • *
  • Posts: 552
    • View Profile
    • Donate to Member
c.gingerich, RunAndKill works like a charm.  Does exactly what I asked for.  Thank you!

What more did you want to do with it??

I also want to thank the others for their suggestions.  Really helpful folks here.



c.gingerich

  • Supporting Member
  • Joined in 2011
  • **
  • Posts: 748
    • View Profile
    • The Blind House
    • Donate to Member
I wanted to add a check to see if the program that is going to be run, is running already running and was going to add a task icon in the tray so it can be killed early if needed. I think that is it for now unless I think of something else. I'll add these items as soon as I can and make a post for it on my site as well as in the "Announce Your Software/Service/Product" section here on DC.

I'm glad you like it and it works well for you.  :Thmbsup:

c.gingerich

  • Supporting Member
  • Joined in 2011
  • **
  • Posts: 748
    • View Profile
    • The Blind House
    • Donate to Member
Here is the page as well as an update. I added the items from previous post.

http://starpunch.blogspot.com/2013/06/run-and-kill.html

Ath

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 3,612
    • View Profile
    • Donate to Member
http://starpunch.blogspot.com/2013/06/run-and-kill.html
Hm, the download doesn't seem to work from here (Both FF and Chrome give a GoogleDrive 'not found error')

c.gingerich

  • Supporting Member
  • Joined in 2011
  • **
  • Posts: 748
    • View Profile
    • The Blind House
    • Donate to Member
Sorry about that. Give it a try again, the file didn't completely upload. Should be working now.

Ath

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 3,612
    • View Profile
    • Donate to Member
Much better, thanks :up:

Tinman57

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 1,702
    • View Profile
    • Donate to Member

  I've been trying to download it for weeks now, but the server is always busy, which is about par with GoOgle.com....  I tried it once more tonight with the same results, so I have officially given up on it.....

c.gingerich

  • Supporting Member
  • Joined in 2011
  • **
  • Posts: 748
    • View Profile
    • The Blind House
    • Donate to Member
very sorry. Does dropbox work for you? Here is a link to the file. https://dl.dropboxusercontent.com/u/137938/downloads/RunAndKill.zip

shmuel1

  • Supporting Member
  • Joined in 2012
  • **
  • default avatar
  • Posts: 48
    • View Profile
    • Donate to Member

nkormanik

  • Participant
  • Joined in 2010
  • *
  • Posts: 552
    • View Profile
    • Donate to Member
Strange case....  AceReader Pro.  Set "RunAndKill" to terminate it after ONE minute.  When the one minute is up, the RunAndKill icon in the system tray disappears, but AceReader appears totally unaffected, still continues on uninterrupted.

Here's the ini file line specifying one minute:

killtime=00:01:00

Some additional weirdness about this particular AceReader program:

-- the AceReader exe requires an additional parameter, "Server"

I typed this parameter into the RunAndKill ini file, following the exe path as follows:

exe="C:\Program Files\AceReader Pro\ace.exe" Server

-- AceReader requires being started from WITHIN a certain directory, "C:\Documents and Settings\All Users\Application Data\AceReader Pro\"

In order to accomplish this, I decided to copy RunAndKill, plus the ini file, INTO that folder.  Then I created a shortcut to it on my desktop.

Any idea why AceReader doesn't get KILLED, like it's supposed to??

By the way, using Windows Task Manager... I can see ace.exe running, and I can End Process, and AceReader does get terminated.  Same as I was hoping RunAndKill would do.

Much thanks,
Nicholas Kormanik


« Last Edit: November 20, 2013, 01:34 AM by nkormanik »

c.gingerich

  • Supporting Member
  • Joined in 2011
  • **
  • Posts: 748
    • View Profile
    • The Blind House
    • Donate to Member
Nicholas - I'll take a look at this and get back to you as soon as I can.

c.gingerich

  • Supporting Member
  • Joined in 2011
  • **
  • Posts: 748
    • View Profile
    • The Blind House
    • Donate to Member
I updated RunAndKill, please give it a try again.

http://starpunch.blo...06/run-and-kill.html

nkormanik

  • Participant
  • Joined in 2010
  • *
  • Posts: 552
    • View Profile
    • Donate to Member
Chris, what a bummer.  Ace.exe still alive and kicking, even with your new version.  I can see it in Windows Task Manager.  And terminating from WTM really does kill it dead in its tracks.

What about just simply doing the kill part?  I'll load the program first.  Then double-click a c.gingerich "Kill."  And in xx minutes the program gets friggin nuked!!

"Kill" can ask for the program name to be nuked (same as what WTM shows, ace.exe), and the time to wait before nuking.  Maybe no need for user to even enter a path (in ini file), as, in present example, ace.exe is the only one with that name running.

"Kill" would be adding for user just the one additional step of starting the initial program first, before running the "Kill" grand terminator.


c.gingerich

  • Supporting Member
  • Joined in 2011
  • **
  • Posts: 748
    • View Profile
    • The Blind House
    • Donate to Member
You run it with a parameter correct?  That might be why it's not killing it. Let me look at it again and I'll get back to you. I love a challenge. 

nkormanik

  • Participant
  • Joined in 2010
  • *
  • Posts: 552
    • View Profile
    • Donate to Member
Correct.  Parameter is "Server"

exe="C:\Program Files\AceReader Pro\ace.exe" Server

Thank goodness for those rare folks that love a challenge.

Challenges seem to be everywhere.


nkormanik

  • Participant
  • Joined in 2010
  • *
  • Posts: 552
    • View Profile
    • Donate to Member
In Windows Task Manager... there is no parameter shown after the program name.

Just "ace.exe"


c.gingerich

  • Supporting Member
  • Joined in 2011
  • **
  • Posts: 748
    • View Profile
    • The Blind House
    • Donate to Member
True, but I set my app to look at the whole string (yeah I should have thought about that) and use it to kill the task. So it is not killing right b/c of the parameter. I should be able to fix it easily. I'll get to it tomorrow and should have an update by the evening.

c.gingerich

  • Supporting Member
  • Joined in 2011
  • **
  • Posts: 748
    • View Profile
    • The Blind House
    • Donate to Member
Give it a try again. I added a parameter option to the ini file. See the included ini file for example.

http://starpunch.blo...06/run-and-kill.html

Fingers crossed that this one works for you! :-)  :Thmbsup: