I’ve put together some PS code that does the following inside of a larger PS script:
- Test if an IE process is already running
- If IE is not already running, start a new process, open site one in that process then open site two in the foreground tab of that process
Make the IE process full screen
If (-Not (Get-Process IExplore -ErrorAction SilentlyContinue)) { $navOpenInForegroundTab = 0x10000; $ie = New-Object -Com InternetExplorer.Application $ie.Visible = $True; $ie.Navigate2("https://stackoverflow.com"); $ie.Navigate2("http://superuser.com", $navOpenInForegroundTab); $sw = @' [DllImport("user32.dll")] public static extern int ShowWindow(int hwnd, int nCmdShow); '@ $type = Add-Type -Name ShowWindow2 -MemberDefinition $sw -Language CSharpVersion3 -Namespace Utils -PassThru $type::ShowWindow($ie.hwnd, 3) # 3 = maximize }
Everything seems to work fine, except that after this code runs, it shows the number 24 in the PowerShell window (I am launching PS from the command line). Can anyone tell me why 24 is being displayed when I run the above code and is it possible to stop it from being displayed?
$type::ShowWindow($ie.hwnd, 3) | out-null.