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()
{
param
(
[string]$arg1,
[string]$keys
)
$wshell = New-Object -ComObject wscript.shell;
$wshell.AppActivate([string]$arg1);
Start-Sleep 1;
$wshell.SendKeys([string]$keys);
}
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?