Kill Navision from Inside

DontWorryDontWorry Member Posts: 4
edited 2004-06-15 in Navision Attain
Good Evening,

how can i kill a navision client from his code? for example, if a form timer arrives at 15 minutes, kill navision. is possible?

Thank you so much
Cheers!!!

DontWorry

Comments

  • WarfoxWarfox Member Posts: 53
    Hy,
    why don´t you use the windows kill command:

    For Example like this:

    OnTimer()
    SHELL(kill fin.exe);
  • oleschjoetholeschjoeth Member Posts: 74
    The problem with Windows kill is that it only kilss the session on the client, not on the server. For that, check with http://www.expandit.com

    Regards,
    Ole
  • RobertMoRobertMo Member Posts: 484
    you can also try PsKill ! It works also for remote computers !
    http://www.sysinternals.com/ntw2k/freeware/pskill.shtml

    Navision code looks like:
    SHELL('pskill finsql.exe');
    
    or
    SHELL('pskill fin.exe');
    
               ®obi           
    ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  • oleschjoetholeschjoeth Member Posts: 74
    Hi Robi,

    does pskill actually kill the client's session on the server?

    (P.S. Thanks for link yesterday :D )

    Regards,
    Ole
  • RobertMoRobertMo Member Posts: 484
    I tried it only locally, but documentation on sysinternals site say it can,
    Usage: pskill [\\computer [-u username [-p password]]] <process Id or name>
    -u Specifies optional user name for login to
    remote computer.
    -p Specifies optional password for user name. If you omit this
    you will be prompted to enter a hidden password.
    And I believe SysInternals since they have the best win tools I have seen and most of them are <100k, which means they doing it at the very low level... An they work exactlly as said...
               ®obi           
    ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  • oleschjoetholeschjoeth Member Posts: 74
    Hi Robi,

    It seems to work - at least no sessions appear to be "hanging" on our sql server 8)

    Regards,
    Ole
  • janpieterjanpieter Member Posts: 298
    I think the best way to friendly close navision is to create a activex DLL and code as following (visual basic 6 example):
    Option Explicit
    
    private Declare Function SendMessage Lib "user32" _
                                        Alias "SendMessageA" (ByVal hwnd As Long, _
                                                              ByVal wMsg As Long, _
                                                              ByVal wParam As Long, _
                                                              lParam As Any) As Long
    
    Private Declare Function GetForegroundWindow Lib "user32" () As Long
    Private Declare Function GetParent Lib "user32" (ByVal hwnd As Long) As Long
    
    private Const WM_CLOSE = &H10
    
    
    Public sub CloseNavision()
        SendMessage getNavHwnd, WM_CLOSE, 0, 0
    End Function
    
    Private Function GetNavHwnd() as long
        Dim tmphwnd As Long
        tmphwnd = GetForegroundWindow
        Do
            getNavHwnd = tmphwnd
            tmphwnd = GetParent(tmphwnd)
        Loop Until tmphwnd = 0
    End Sub
    

    Reference the DLL and call CloseNavision. It should work I think. Didn't test it but parts of the code i'm using in my code so i only brought a few modules together.

    This won't work when you have any form open that has code that prevents that form from closing. In that way navision is prevented from closing. It won't work while messagboxes are still pending (neither will your timer trigger fire in that case).

    Enjoy :D
    In a world without Borders or Fences, who needs Windows and Gates?
  • SavatageSavatage Member Posts: 7,142
    ooooh I just noticed it is $495.00

    was $200.00 just a month ago - talk about inflation
  • dmccraedmccrae Member, Microsoft Employee Posts: 144
    What version are you using? From 3.70 on SQL you can kill a session by deleting the record from the Session table provided it is not your own.

    (This is available on both server platforms in 4.0).
    Dean McCrae - Senior Software Developer, NAV Server & Tools

    This posting is provided "AS IS" with no warranties, and confers no rights.
  • Fredrik_GustafssonFredrik_Gustafsson Member Posts: 14
    One problem with using kill or pskill is if the user runs two clients on his desktop and one of them reaches the timeout limit. Then any of them can be closed down.

    When the user is in the middle of work, suddenly the client closes down...

    Further on, kill cannot be used in Terminal Server or Citrix.

    But if it was possible to find out the client's process ID, then the correct client could be closed down. Waterproof solution.
Sign In or Register to comment.