Jump to content

Auto Check For Running Application And Launch


un4given1

Recommended Posts

I'm looking for a way that I can set a PC to look for a process every 15 minutes and to launch a file if it's not running. I need it to be hidden.

Windows task scheduler does not work in a manner where it is able to run every 15 minutes. I created a batch file that works, I just don't have a way to launch it every 15 minutes.

Just to give you an idea... When a user logs on I want this file to run. I would need it to run every 15 minutes. It will be checking to see if Outlook is running and if it isn't it will launch it.

I can't get our employees to leave it running, and it's necessary because it notifies them of any updates on thier tickets in SharePoint Services. It's also our main communication tool.

Thank you!

Link to comment
Share on other sites


@fftb

Schedule wizard looks very versitile, but since it runs in the tray, users can still easily shut it down.

BTW, what ever happened to Count Duckula? Is he still on? I used to love that show.

@u41

I have some application kicker code that runs as a service. I used it in a project to periodically check for backup files and run backup if they didn't exist. Wouldn't be hard to modify to run your batch file. With a little extra code it could check for process directly. It is written in VB6. Do you code? If so I could send you the source if you are interested. If not, I could modify it for you when I get a chance.

dman

Link to comment
Share on other sites

  • 2 weeks later...

@un4given1,

I put together some code to launch app at intervals. One is a service and one an application. As I was playing with the service app I realized it might not be appropriate for launching outlook. In order for a service to be able to interact with the desktop it must run in the context of the local service account. Great for backup programs and generic apps, but not so good for apps that read user profiles like outlook. Don’t know if there is a way around this but I am curious. I attached the code anyway just in case you might have a need for it or just want to look. It is very generic and could be used to make any kind of service. AppKicker.exe is the service, and AppKicker_ctl.exe is the control panel to install the service. If you use it to launch desktop apps, after you install but before you start the service you must go into the service properties/logon tab and check “allow service to interact with desktop”.

Noting this deficiency I threw together a simple app, AppTimer.exe that will run with no interface, taskbar or tray icon, but appears as a running app in task manager.

Both of these programs will run a batch file located in the app directory in hidden mode at 10 minute intervals. The service runs “AppKicker.bat” and the AppTimer.exe runs “AppTimer.bat”. You can put your code that checks for outlook running and launch (or anything else) in this file.

All of the code is in VB6 if you want to play with it. Hope you can use it, but even if not it was good to dust it off (the code and the brain cobwebs).

dman

applaunchers.zip

Link to comment
Share on other sites

You said you would try, but I think that I have an elegant solution. XYNTService is a program that lets you turn any exe /bat /java file into a Windows Service. It also has monitoring built in so that if the process stops, it will restart it. It also has an option for interaction, so that you can set it off, and then it is completely hidden.

I use it to start java services, and it works wonderfully.( it is free.)

http://www.codeproject.com/system/xyntservice.asp

http://mysite.verizon.net/XiangYangL/XYNTService.htm

Link to comment
Share on other sites

@purewaveform

This looks like neat code, but still suffers from the same problem as my service code as far as running programs that access the desktop and need to read user settings.

The UserInterface property controls whether a logged on user can see the processes created by XYNTService. However, this only works when XYNTService is running under the local system account, which is the default. In this case, processes created by XYNTService will not be able to access a specific user's settings (e-mail profiles, etc.). You can configure XYNTService to run under a user account, which is done easily from the Control Panel (double click the Services icon and then double click XYNTService in the installed services list to bring up a dialog box).
Link to comment
Share on other sites

Well if I understand you corectly then I would put a task in theis startup folder that would do the launching. That isnt any big deal, sorry I didnt understand that from the beginning.

tasklist > temp.list
find /N /I "outlook" temp.list

That code will find if the task is there. Just wrap that in a cmd file and add a sleep 15000, and make sure that you do an echo off at the top and cmdow @ /HID that way theprompt will be hidden, when the user logs off then it should kill the process. Also remember in the batch file to check for the return code from the find. that way you will know if it found the process or not. IF you dont get what this all says, then ask and I will write the whole script out, but I want you to experiment with the if and the loop.

write if you have more questdions.

Link to comment
Share on other sites

@purewaveform,

Looks like a good solution except sleep is not a standard XP command. As far as I know it is part of Windows 2003 Resource Kit. You can imitate it with ping somehow, don't remember, but in any case you are back to adding external programs.

un4given said he already has cmd to find running proc and launch, he is just looking for timer.

BTW, I do most of my programming in VFP and VB. I only ever used cmd files for vey simple tasks, and I'm blown away by some of the complex tasks MSFN members can accomplish with the "lowly" batch. Thanks for the education guys.

Link to comment
Share on other sites

if the time is only the issue, then in both vb script, and vb there is a timer() function that will return the numbers of seconds past midnight. Then just keep track of last check, and then just cycle through, and in vb script run an externall javascript call to its sleep fucntion. you do that by creating the javascript object. Then you just compare the timer to the current timer, and if greater then do something, else javascript sleep and try again later. This way the whole script is just vb, adn a little Javascript, and all you need to do is make sure that you have ie6 on the machine for it to run. Then still just put it into the startup folder, and I would still have a cmd file launch the vbscript file so that you can hide the window.

Link to comment
Share on other sites

Not sure how this is simpler. My VB app uses timer to launch batch in hidden window. No IE, Java, vbscript warnings... just put it in startup folder or run key. It is fairly simple solution.

Not even sure if he is going to use it, but it has been fun discussing the problem with you.

Link to comment
Share on other sites

  • 2 weeks later...

Link above not to hot!

To set up a task that runs every 15 minutes, here are the steps:

Start->Control Panel->Scheduled Tasks->Add Scheduled Task.

Click Next.

Select any program (we’ll be replacing this so it doesn’t matter) and hit Next.

Name the task “MT Periodic Tasks”.

Select Perform This Task Daily and hit Next. Hit Next (accept the default start time/date).

If prompted, enter your username and password (twice for the password) and hit Next.

Check “Open advanced properties for this task” and hit Finish. The advanced properties will open.

Change the Run: box to read “perl run-periodic-tasks”.

Change the Start In: box to the name of the directory where your run-periodic-tasks script is (for example C:\Inetpub\wwwroot\mt\tools).

Select the Schedule tab and click Advanced. Pick today’s date as the start date, and check Repeat Task. Set the Every boxes to whatever your repeat rate should be (for instance 15 and minutes). Check the “Duration” button, and set it to 23 hours and 59 minutes and click OK. This will run the task every day and repeat it every 15 minutes for 24 hours. At the end of the 24 hours it will be a new day, and the task will start over — repeating every 15 minutes for another 24 hours. This part of the interface is especially unintuitive; somebody should make a new interface for Task Scheduler that actually makes sense to normal people. :-P

Change the start time to 15 minutes from now and click OK. If you are prompted again for your username and password, put them in and hit OK.

Your task will now run every 15 minutes until you disable or delete it.

Try this link http://www.randomtree.org/eric/techblog/archives/2004/09/

some good responses to it as well?

Link to comment
Share on other sites

Might be making this too hard. If you can run batch hidden on startup, try this:

@echo off

:loop
"C:\Program Files\Microsoft Office\Office10\OUTLOOK.EXE"
goto loop

exit

Any time Outlook is closed, it will be started again.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...