[seems solved] Return value of a function

Hello everybody,

At starting of a Windows session, I have a few windows that are opened when launching programs, and the user has to close them before doing anything else.

It would be nice to close them automatically.

Let us take the example of PowerShell.

closeWin "Windows PowerShell" "exit~"

function closeWin()
    $wshell = New-Object -ComObject wscript.shell;
    Start-Sleep 1;

Well, it closes the window, and then displays False.

Instead of displaying True, I should like the script to display “Window not found”, I think it would be more explicit.

Well, is it AppActivate, that returns a value?

Oh, it seems so.

    $t = $wshell.AppActivate([string]$arg1);
        "$arg1 : window not found";
        "$arg1 : window closed";

and strangely, it worked only after I launched it three times.
So, the return value is the answer to the question “does this raise an error ?”
If I search AppActivate on Internet, I have the forums questions before the documentation.

Oh, in PowerShell I typed update-help, maybe next time I get something more useful.


Au caractère Ligne:1 : 1
+ update-help
+ ~~~~~~~~~~~
    + CategoryInfo          : ResourceUnavailable: (:) [Update-Help], Exceptio 
    + FullyQualifiedErrorId : UnableToRetrieveHelpInfoXml,Microsoft.PowerShell