AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Closing applications in remote windows

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
sl_alagappan



Joined: 03 Mar 2004
Posts: 17

PostPosted: Sat Apr 10, 2004 5:28 am    Post subject: Closing applications in remote windows Reply with quote

Frequently, I need to close and restart some java based windows ( running in DOS environment ) in Windows NT 4 Server.

I wish to close the windows in the remote Widnows NT Server from a client machine usign AutoHotkey.


any idea or suggestion on how to close a remote application window from a client machine?
Back to top
View user's profile Send private message
Beastmaster
Guest





PostPosted: Sat Apr 10, 2004 9:36 am    Post subject: Reply with quote

Please check if PSExec (from your local box) could trigger/execute an AHK script (left on the remote box).

Additionaly you could use VNC (or one of his clones eg. RealVNC or ThightVNC, to see what's going on - cross platform!)
Back to top
Beastmaster
Guest





PostPosted: Sat Apr 10, 2004 9:43 am    Post subject: Reply with quote

If you've accomplished how to identify such JAVA/DOS window, you could run an AHK script (24/7 or scheduled) on the remote box to close that window, without any need of remote action.
Back to top
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10480

PostPosted: Sat Apr 10, 2004 12:32 pm    Post subject: Reply with quote

Quote:
you could run an AHK script (24/7 or scheduled) on the remote box to close that window, without any need of remote action.

Similar to the above idea, you could have a script running on the remote machine that watches for certain semaphore (signal) file to exist. Such a file can be created via a mapped drive on either machine (or perhaps by using a UNC directly). For example:
Code:
Loop
{
    IfExist, M:\StartJob.txt  ; A remote user created this file to tell us to start.
    {
        FileDelete, M:\StartJob.txt  ; Reset for the next time
        Run, Whatever.exe
    }
    Sleep, 1000
}
Back to top
View user's profile Send private message Send e-mail
beardboy



Joined: 02 Mar 2004
Posts: 444
Location: SLC, Utah

PostPosted: Sat Apr 10, 2004 2:27 pm    Post subject: Reply with quote

Here is an example of a program I wrote that runs on remote computers that lets me start any application I want remotely and kill remote programs.

Code:
Loop
{
  IFExist, %A_SCRIPTDIR%\trimmenu.ini
  {
    GoSub, INI
  }
  Sleep, 1000
}

INI:
IniRead, type, %A_SCRIPTDIR%\trimmenu.ini, General, Type
IniRead, program, %A_SCRIPTDIR%\trimmenu.ini, General, Program
IniRead, options, %A_SCRIPTDIR%\trimmenu.ini, General, Options
if type = kill
{
  if options = winkill
  {
    WinKill, %program%
  }
  if options = rkill
  {
    RunWait, %comspec% /c rkill /nkill \\%computername% %program%,,hide
  }
}
if type = start
{
  Run, %program% %options%
}
FileDelete, %A_SCRIPTDIR%\trimmenu.ini
return


rkill can be found at http://www.autohotkey.com/forum/viewtopic.php?t=95

Then on my local PC I wrote a batch job to create the INI file and copy it to the remote PC.

Code:
@echo off
set v=%1
Title Trimmenu Start / Kill
echo Trimmenu Start / Kill
:start
echo ------------------------------------------------
IF "%v%" == "" set /p computer=What PC would you like to do something on?
IF NOT "%v%" == "" set computer=%1
IF "%computer%" == "exit" GOTO END
set /p sork=Would you like to start or kill?
set /p program=What program (remember full path if needed)?
set /p options=Options (Example: /c /d)?

IF NOT EXIST \\%computer%\c$ echo %computer%: Computer is not available&set v=&GOTO START
echo [General]>trimmenu.ini
echo Type=%sork%>>trimmenu.ini
echo Program=%program%>>trimmenu.ini
echo Options=%options%>>trimmenu.ini
move trimmenu.ini \\%computer%\c\winnt\
echo.
echo Command sent to %computer%

echo.
IF "%2" == "done" GOTO END
set v=&GOTO START

:END
title C:\WINNT\System32\cmd.exe


thanks,
beardboy
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
sl_alagappan



Joined: 03 Mar 2004
Posts: 17

PostPosted: Mon Apr 12, 2004 4:03 am    Post subject: Reply with quote

thanks all for yr replies.

I hv implemented similar method to close the remote windows ( a schedular running to check for existance of a file. If found, the autoit v2 script will close all the remote windows and restart the app ).

But the problem, I face is that, when u close and restart the remote windows for the first time, there is no problem. but for the second and consecutive times, there are kernel errors from Windows NT when I kill process using kill.exe. Not sure whether it is due to windows nt or the java app or the autoit v2 script.. I need to come down to office to restart the server manually in this case during night times.

I know the window title and text of the windows to be closed.


What I want is to close windows in order. Once closed a window, check whether it has been safely closed before closing the next window.

I have an existing VB 6 application which I need to interact with. Once the user click a button in VB app, the vb program should iniate the window closing process using autohotkey. For each window close, I need a confirmation from autohotkey script whether the window is safey closed to my vb program. Once all windows are closed, I need to get confirmation to the vb program so as to inform users what is happening on the remote server.

any possible way of achieving this without affecting windows nt?
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10480

PostPosted: Mon Apr 12, 2004 4:11 am    Post subject: Reply with quote

WinClose and WinKill both support an optional "wait until closed" parameter. You could also use WinWaitClose.
Back to top
View user's profile Send private message Send e-mail
Beastmaster
Guest





PostPosted: Mon Apr 12, 2004 9:12 am    Post subject: Reply with quote

... and you could set/hold the current status of each window/process in an INI:

[PROCSTAT]
win1=YES
win2=YES
win3=NO
VBConfirmation=NO
Back to top
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group