Sign in to follow this  
Followers 0
rudi

Kill a Window as silently as ProcessKill() does

5 posts in this topic

Hello,

I'm stuck, and propably this is an ugly and not efficent way to do what I aim :) at, so maybe it's better first to tell what I want to do:

Given is a ERP system, that has to be made accessible through Terminal Server Session from the Internet (VPN tunnel), but when accessed this way only one certain user shall be able to login (restricted access inside ERP).

So I thought about watching the running instances of that ERP system, if found, get the user, if the user isn't "hotline" then immediately kill that one.

Here is my "50 + something" approach ;) I'm still not happy about at all:

if WinExists("[REGEXPTITLE:b 2® - Enterprise Resource Planning - Firma 1 - Benutzer: (.*) - Session-ID:.*]") Then 
    ; b2 is running with status "logged in" at least once
    $B2List = WinList("[REGEXPTITLE:b 2® - Enterprise Resource Planning - Firma 1 - Benutzer: (.*) - Session-ID:.*]") ; get name(s) of user(s)
    MsgBox(0,"",$B2List[0][0] & " b2 Instanzen sind geöffnet.")
    for $i = 1 to $B2List[0][0]
        if StringRegExp($B2List[$i][0],"b 2® - Enterprise Resource Planning - Firma 1 - Benutzer: (hotline) - Session-ID:.*",0) Then 
        ; do nothing, user "hotline" is OK.
        Else
            WinKill($B2List[$i][1]) 
            ; winkill doesn't kill immediatly + silently. 
            ; ProcessKill() does, but how to get the PID from the "HWND" WinList() returns???
        EndIf
    Next
EndIf

Tired - any help appreciated - Rudi.


Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Share this post


Link to post
Share on other sites



Terminal Server allows management of which users can access which applications. Why is any unauthorized user able to see the app at all?

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

; winkill doesn't kill immediatly + silently.

; ProcessKill() does, but how to get the PID from the "HWND" WinList() returns???

$Pid = WinGetProcess("Untitled - Notepad")
ProcessClose($Pid)
Edited by kip

Share this post


Link to post
Share on other sites

Hi.

Terminal Server allows management of which users can access which applications. Why is any unauthorized user able to see the app at all?

:)

No, no: I obviously didn't phrase my question precisely enough:

The User can ONLY access the allowed applications. But within the ERP program it is possible to login to the ERP system with a user that shall not be used, as too much information is accessible /modifyable. The ERP program's title bar presents who is curently logged in to the ERP system. And if there is somebody else logged in but "hotline" then I need to kill that window. (e.g. no prices outside the campus LAN among others limitations that have to be enforced).

Regards, Rudi.


Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Hello,

Thanks! :), now it does the trick :D

if WinExists("[REGEXPTITLE:b 2® - Enterprise Resource Planning - Firma 1 - Benutzer: (.*) - Session-ID:.*]") Then 
    ; b2 is running with status "logged in" at least once
    $B2List = WinList("[REGEXPTITLE:b 2® - Enterprise Resource Planning - Firma 1 - Benutzer: (.*) - Session-ID:.*]") ; get name(s) of user(s)
    MsgBox(0,"",$B2List[0][0] & " b2 Instanzen sind geöffnet.")
    for $i = 1 to $B2List[0][0]
        if StringRegExp($B2List[$i][0],"b 2® - Enterprise Resource Planning - Firma 1 - Benutzer: (hotline) - Session-ID:.*",0) Then 
        ; do nothing, user "hotline" is OK.
        Else
            ProcessClose(WinGetProcess($B2List[$i][1])) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
        EndIf
    Next
EndIf

Now I can start to play around with array checking (dimensions) and @error handling. ;)

What do you think in general about this approach? (There might be a different, much more efficent way for such a "watchdog")

Regards, Rudi.

Edited by rudi

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Share this post


Link to post
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
Sign in to follow this  
Followers 0