SoftTree Technologies SoftTree Technologies
Technical Support Forums
RegisterSearchFAQMemberlistUsergroupsLog in
Closing User App from 24x7 as a Service

 
Reply to topic    SoftTree Technologies Forum Index » 24x7 Scheduler, Event Server, Automation Suite View previous topic
View next topic
Closing User App from 24x7 as a Service
Author Message
Greg Morris



Joined: 24 May 2002
Posts: 26

Post Closing User App from 24x7 as a Service Reply with quote

We're running 24x7 Scheduler v3.3.3 on XP systems
as a service. We have a tool we use to forcibly close
a certain user app by closing windows of the app.

We're having trouble. Our tool (Closeit) basically
needs to run in the user's Windows session in order
to activate and close the app's windows in that session.
Is this possible from a 24x7 Job launched when 24x7
Scheduler is running as a service? In otherwords, can
I have a job run as "currently logged in user" so that
the job's program runs in the currently logged in user's
session?

Thank you,
Greg

Mon Oct 21, 2002 4:21 pm View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7858

Post Re: Closing User App from 24x7 as a Service Reply with quote

This is possible only if the service is running under LocalSystem account and "Enable service to interact with Desktop" option enabled in the Control Panel Services applet.

I suggest that you use ProcessKill statement in 24x7 to forcibly close an application. All you need is the name of the main executable file of the application that you want to close. For example to kill 24x7 you can use the following code
Dim process_id, number
ProcessGetID "24X7.EXE", process_id
ProcessKill process_id

24x7 also provide direct methods for closing windows of any graphical application, but again it will not work if executed from the service.

: We're running 24x7 Scheduler v3.3.3 on XP systems
: as a service. We have a tool we use to forcibly close
: a certain user app by closing windows of the app.

: We're having trouble. Our tool (Closeit) basically
: needs to run in the user's Windows session in order
: to activate and close the app's windows in that session.
: Is this possible from a 24x7 Job launched when 24x7
: Scheduler is running as a service? In otherwords, can
: I have a job run as "currently logged in user" so that
: the job's program runs in the currently logged in user's
: session?

: Thank you,
: Greg

Mon Oct 21, 2002 5:13 pm View user's profile Send private message
Greg Morris



Joined: 24 May 2002
Posts: 26

Post Re: Closing User App from 24x7 as a Service Reply with quote

: This is possible only if the service is running under LocalSystem account and
: "Enable service to interact with Desktop" option enabled in the
: Control Panel Services applet.

: I suggest that you use ProcessKill statement in 24x7 to forcibly close an
: application. All you need is the name of the main executable file of the
: application that you want to close. For example to kill 24x7 you can use
: the following code
: Dim process_id, number
: ProcessGetID "24X7.EXE", process_id
: ProcessKill process_id

: 24x7 also provide direct methods for closing windows of any graphical
: application, but again it will not work if executed from the service.

Well, I thought I had this working. I configured 24x7 service
with "interact with Desktop", and observed my tool close
the other app. BUT now, I can't repeat that success.

Our tool is a WinBatch program that activates the apps'
windows and closes them. We can't do a forced close of
the process because it will leave the apps' database
dirty.

So, what you're saying is I should be able to do what
I am attempting, as long as "interact with desktop"
is checked in the 24x7 Service properties. Right?

Fri Oct 25, 2002 4:38 pm View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7858

Post Re: Closing User App from 24x7 as a Service Reply with quote

The application doesn't have to be active to be closed.

You can use WindowFind ... WindowClose approach to close application window. It is like clicking the X box in the window title bar.
If it is an MDI application you just need to close one window - the frame, which in turn should close all other windows of that application.

For examples of using WindowClose browse in the on-line help to the WindowClose topic then press the Examples button on the help window toolbar.

24x7 supports large number of other commands for manipulating Windows and Processes as well as commands for simulating user keystrokes and mouse clicks, not to mention the 24x7 MacroRecorder that is specifically designed to run interactive applications.
If you need with the code, please feel free to ask.

: Well, I thought I had this working. I configured 24x7 service
: with "interact with Desktop", and observed my tool close
: the other app. BUT now, I can't repeat that success.

: Our tool is a WinBatch program that activates the apps'
: windows and closes them. We can't do a forced close of
: the process because it will leave the apps' database
: dirty.

: So, what you're saying is I should be able to do what
: I am attempting, as long as "interact with desktop"
: is checked in the 24x7 Service properties. Right?

Fri Oct 25, 2002 5:03 pm View user's profile Send private message
Greg Morris



Joined: 24 May 2002
Posts: 26

Post Re: Closing User App from 24x7 as a Service Reply with quote

Basically, what you're suggesting in JAL is what our current tool does. Our current tool
took a while to get ironed out because of the idosynchrocies in the app. Our current tool works
well, when it can interact with the app in the users desktop.
For example, launched from 24x7 running as an application works fine.
If I can't get our current tool to work from 24x7 service, won't I find
the same problems with JAL WindowFind, et. al?

I just seem to be having a problem using 24x7 Service to launch apps
that need to interact with the user. For example, launching NOTEPAD.EXE.
When I did that, I see NOTEPAD.EXE process running in Task Manager,
but it is not visible to me.

Am I missing something here?

: The application doesn't have to be active to be closed.

: You can use WindowFind ... WindowClose approach to close application window.
: It is like clicking the X box in the window title bar.
: If it is an MDI application you just need to close one window - the frame,
: which in turn should close all other windows of that application.

: For examples of using WindowClose browse in the on-line help to the
: WindowClose topic then press the Examples button on the help window
: toolbar.

: 24x7 supports large number of other commands for manipulating Windows and
: Processes as well as commands for simulating user keystrokes and mouse
: clicks, not to mention the 24x7 MacroRecorder that is specifically
: designed to run interactive applications.
: If you need with the code, please feel free to ask.

Fri Oct 25, 2002 5:35 pm View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7858

Post Re: Closing User App from 24x7 as a Service Reply with quote

It should be visible if the service is running under LocalSystem and with the "interact" option.
You need to restart the service after you change service settings.

The 24x7 icon should also appear in the system tray.

: Basically, what you're suggesting in JAL is what our current tool does. Our
: current tool
: took a while to get ironed out because of the idosynchrocies in the app. Our
: current tool works
: well, when it can interact with the app in the users desktop.
: For example, launched from 24x7 running as an application works fine.
: If I can't get our current tool to work from 24x7 service, won't I find
: the same problems with JAL WindowFind, et. al?

: I just seem to be having a problem using 24x7 Service to launch apps
: that need to interact with the user. For example, launching NOTEPAD.EXE.
: When I did that, I see NOTEPAD.EXE process running in Task Manager,
: but it is not visible to me.

: Am I missing something here?

Fri Oct 25, 2002 5:52 pm View user's profile Send private message
Greg Morris



Joined: 24 May 2002
Posts: 26

Post Re: Closing User App from 24x7 as a Service Reply with quote

Doesn't work. I have the icon in the systray. I can
simulate this from 24x7 in application mode if I
configure my job to run in a "hidden" window. It is as if
any program launched from 24x7 service is launched in
a "hidden" window. I've tried v3.3.3 and v3.3.5; both
do not work for me. I'm running on XP.

: It should be visible if the service is running under LocalSystem and with the
: "interact" option.
: You need to restart the service after you change service settings.

: The 24x7 icon should also appear in the system tray.

Mon Oct 28, 2002 5:10 pm View user's profile Send private message
Greg Morris



Joined: 24 May 2002
Posts: 26

Post Re: Closing User App from 24x7 as a Service Reply with quote

Help! Are you able to get your suggestion to work on XP or W2K?
I cannot. I do have an icon in systray, but everything I
launch from 24x7 service is apparently "hidden". I see the process
running in task manager, but the process is not visible.
I have even tried RunAndWait() to launch it; still doesn't
work when 24x7 is running as a service. Is someone checking
into this further?
: Doesn't work. I have the icon in the systray. I can
: simulate this from 24x7 in application mode if I
: configure my job to run in a "hidden" window. It is as if
: any program launched from 24x7 service is launched in
: a "hidden" window. I've tried v3.3.3 and v3.3.5; both
: do not work for me. I'm running on XP.

:: It should be visible if the service is running under LocalSystem and with the
:: "interact" option.
:: You need to restart the service after you change service settings.

:: The 24x7 icon should also appear in the system tray.


Tue Oct 29, 2002 5:18 pm View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7858

Post Re: Closing User App from 24x7 as a Service Reply with quote

I am checking it right now on W2K computer. I will get back to you soon.

: Help! Are you able to get your suggestion to work on XP or W2K?
: I cannot. I do have an icon in systray, but everything I
: launch from 24x7 service is apparently "hidden". I see the process
: running in task manager, but the process is not visible.
: I have even tried RunAndWait() to launch it; still doesn't
: work when 24x7 is running as a service. Is someone checking
: into this further?

Tue Oct 29, 2002 5:31 pm View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7858

Post Re: Closing User App from 24x7 as a Service Reply with quote

Here is what I found out. Processes started by the service are visible but they run on an invisible desktop that Windows allocates for services and their processes. That's why you can see your programs in the Task Manager but not on the screen.

However, you can still manipulate process windows even if the process itself runs on such invisible Desktop. Please excuse me for misleading, in order to manipulate process windows you need to uncheck "Allow service to interact with the Desktop" option for 24x7 service. This will make the service and the launched processes to run on the same Desktop and thus allow the service to access process windows. Below is the script that I used for testing:

Dim pid, number
Dim win, number

Run "notepad.exe", "", pid
LogAddMessageEx "INFO", @V"job_id", "@V"job_name"", pid
Wait 5

WindowFind "Untitled - Notepad", win
LogAddMessageEx "INFO", @V"job_id", "@V"job_name"", win

ifThen win, CLOSE_IT
Exit

CLOSE_IT:
WindowClose win

: Help! Are you able to get your suggestion to work on XP or W2K?
: I cannot. I do have an icon in systray, but everything I
: launch from 24x7 service is apparently "hidden". I see the process
: running in task manager, but the process is not visible.
: I have even tried RunAndWait() to launch it; still doesn't
: work when 24x7 is running as a service. Is someone checking
: into this further?

Wed Oct 30, 2002 10:04 am View user's profile Send private message
Greg Morris



Joined: 24 May 2002
Posts: 26

Post Re: Closing User App from 24x7 as a Service Reply with quote

Thank you for trying to help, but what I need to do is
launch a job from 24x7 service that can access the CURRENT
LOGGED-IN USER'S desktop in order to gracefully close an app the
user has left running after hours. Your JAL code below may work,
but that's because the WindowFind is finding an app
that was started in the same "invisible desktop". If you open
Notepad as a user, then do the WindowFind from a JAL job
launched by 24x7 service, you will see it doesn't find Notepad.
Or at least that's my experience.

I believe I am concluding 24x7 can't meet our need in this
regard. We really need it to be running as a service so
that we can use it to do things when no user is logged on.
Oh well.

: Here is what I found out. Processes started by the service are visible but
: they run on an invisible desktop that Windows allocates for services and
: their processes. That's why you can see your programs in the Task Manager
: but not on the screen.

: However, you can still manipulate process windows even if the process itself
: runs on such invisible Desktop. Please excuse me for misleading, in order
: to manipulate process windows you need to uncheck "Allow service to
: interact with the Desktop" option for 24x7 service. This will make
: the service and the launched processes to run on the same Desktop and thus
: allow the service to access process windows. Below is the script that I
: used for testing: Dim pid, number
: Dim win, number

: Run "notepad.exe", "", pid
: LogAddMessageEx "INFO", @V"job_id",
: "@V"job_name"", pid
: Wait 5

: WindowFind "Untitled - Notepad", win
: LogAddMessageEx "INFO", @V"job_id",
: "@V"job_name"", win

: ifThen win, CLOSE_IT
: Exit

: CLOSE_IT: WindowClose win

Wed Oct 30, 2002 6:36 pm View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7858

Post Re: Closing User App from 24x7 as a Service Reply with quote

This is not doable in Windows! Applications in Windows cannot access objects on other Desktops.

Since services always run on their own virtual Desktop they cannot access applications running on LOGGED-IN USER'S Desktops.

The only workaround is to run two separate programs that "talk" to each other. One program could run as a service and the other must run on the user's Desktop. Then the service can somehow establish a connection to the other piece and tell it what to do. But this would require implementing the entire inter-process communication interface.

: Thank you for trying to help, but what I need to do is
: launch a job from 24x7 service that can access the CURRENT
: LOGGED-IN USER'S desktop in order to gracefully close an app the
: user has left running after hours. Your JAL code below may work,
: but that's because the WindowFind is finding an app
: that was started in the same "invisible desktop". If you open
: Notepad as a user, then do the WindowFind from a JAL job
: launched by 24x7 service, you will see it doesn't find Notepad.
: Or at least that's my experience.

: I believe I am concluding 24x7 can't meet our need in this
: regard. We really need it to be running as a service so
: that we can use it to do things when no user is logged on.
: Oh well.

Wed Oct 30, 2002 11:01 pm View user's profile Send private message
Greg Morris



Joined: 24 May 2002
Posts: 26

Post Re: Closing User App from 24x7 as a Service Reply with quote

I appreciate your help. From what I've read though, 24x7 was designed to do what
you are saying can't be done, and that is basically allow a program
interact with the user when that program has been launched by the
24x7 service. Please read the statements below from 24x7 documentation.
We purchased a site license with plans to exploit this documented feature!
>>
Not all processes, applications, documents, and .bat files can be
started from the 24x7 Scheduler. In order to run an interactive
application, the application needs to be started with the local system
account, and the "Allow service to interact with desktop" check box
in Services Control Panel Applet must be checked. If the 24x7 schedule
service is set to log on as the local system, scheduled jobs cannot be
validated on the network so they cannot access any network resources. If
you start the 24x7 schedule service with a user account, jobs can be
validated on the network, but they can't have any user interface, because
only the local system has sufficient privileges to allow a service to start
a program on the interactive desktop.

: This is not doable in Windows! Applications in Windows cannot access objects
: on other Desktops.

: Since services always run on their own virtual Desktop they cannot access
: applications running on LOGGED-IN USER'S Desktops.

: The only workaround is to run two separate programs that "talk" to
: each other. One program could run as a service and the other must run on
: the user's Desktop. Then the service can somehow establish a connection to
: the other piece and tell it what to do. But this would require
: implementing the entire inter-process communication interface.

Thu Oct 31, 2002 10:45 am View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7858

Post Re: Closing User App from 24x7 as a Service Reply with quote

I think the dosumentation is incorrect. I guess it supposed to say that user can interract with 24x7 service only when it is running under LocalSystem and with the "Desktop" option turned on. In that case all information messages (job errors, job status display, etc...) displayed by the service as well as 24x7 system tray icon can be seen by the user.

Anyway, I created a little BindDesktop utility that can do what you need. Using this utility you can schedule you program to run on a user desktop. You can also use to run 24x7 with /JOB parameter and have it in turn run a job that can interract or manipulate a user process.
In the last case create a script type job in 24x7 with [no schedule] for the schedule type and a script like the one I posted yesterday. Let's say this job id will be XXX.
Schedule another program type job to be run by the service with the following command line

BindDesktop winsta0\default "C:\Program Files\24x7 Automation 3\24x7.exe" /JOB XXX

Here is the download link for BindDesktop http://www.softtreetech.com/24x7/extras/BindDesktop.exe
Save this file either in 24x7 installation directory or in C:\WinNT.
Run it from the DOS command prompt for description of supported command line parameters.

: I appreciate your help. From what I've read though, 24x7 was designed to do
: what
: you are saying can't be done, and that is basically allow a program
: interact with the user when that program has been launched by the
: 24x7 service. Please read the statements below from 24x7 documentation.
: We purchased a site license with plans to exploit this documented feature!
: Not all processes, applications, documents, and .bat files can be
: started from the 24x7 Scheduler. In order to run an interactive
: application, the application needs to be started with the local system
: account, and the "Allow service to interact with desktop" check box
: in Services Control Panel Applet must be checked. If the 24x7 schedule
: service is set to log on as the local system, scheduled jobs cannot be
: validated on the network so they cannot access any network resources. If
: you start the 24x7 schedule service with a user account, jobs can be
: validated on the network, but they can't have any user interface, because
: only the local system has sufficient privileges to allow a service to start
: a program on the interactive desktop.

Thu Oct 31, 2002 1:05 pm View user's profile Send private message
Greg Morris



Joined: 24 May 2002
Posts: 26

Post Re: Closing User App from 24x7 as a Service Reply with quote

BindDesktop appears it will work for me. THANK YOU VERY MUCH!!

: I think the dosumentation is incorrect. I guess it supposed to say that user
: can interract with 24x7 service only when it is running under LocalSystem
: and with the "Desktop" option turned on. In that case all
: information messages (job errors, job status display, etc...) displayed by
: the service as well as 24x7 system tray icon can be seen by the user.

: Anyway, I created a little BindDesktop utility that can do what you need.
: Using this utility you can schedule you program to run on a user desktop.
: You can also use to run 24x7 with /JOB parameter and have it in turn run a
: job that can interract or manipulate a user process.
: In the last case create a script type job in 24x7 with [no schedule] for the
: schedule type and a script like the one I posted yesterday. Let's say this
: job id will be XXX.
: Schedule another program type job to be run by the service with the following
: command line

: BindDesktop winsta0\default "C:\Program Files\24x7 Automation
: 3\24x7.exe" /JOB XXX

: Here is the download link for BindDesktop
: http://www.softtreetech.com/24x7/extras/BindDesktop.exe
: Save this file either in 24x7 installation directory or in C:\WinNT.
: Run it from the DOS command prompt for description of supported command line
: parameters.

Thu Oct 31, 2002 6:27 pm View user's profile Send private message
Display posts from previous:    
Reply to topic    SoftTree Technologies Forum Index » 24x7 Scheduler, Event Server, Automation Suite All times are GMT - 4 Hours
Page 1 of 1

 
Jump to: 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


 

 

Powered by phpBB © 2001, 2005 phpBB Group
Design by Freestyle XL / Flowers Online.