2

I'm working around an annoyance with the Win 10 start menu that can't handle multiple shortcuts (start menu tiles) to the same executable command. I want to have individual start menu items to open named PuTTY sessions using PuTTY -load SessionName

So, I have created a small powershell (PS) script file for each session like:

# ----Open named PuTTY session----
$PF= ${Env:ProgramFiles}
$exe= "Other\PuTTY\putty.exe"
$session= "Servername (login)"

$PuTTY= Join-Path $PF $exe

& $PuTTY -load $session

I can then create a shortcut to this script, with the shortcut target set to-

powershell.exe <path to ps1 script file>

and pin the shortcut to the start menu.

This works well, but as the script runs you can see a powershell console window flick open and then close as the script runs. I want to get rid of this annoying flicker of the PS console window.

I have experimented with adding the -WindowStyle Hidden and/or -NonInteractive options to the command line in the shortcut, but the annoying flicker of the powershell console still happens.

I would have expected -WindowStyle Hidden to make PS run in the background with no display window. Is that not the case? or is there another way to achieve a truly "invisible" PS script?

Incans
  • 182
  • 9
  • 2
    that parameter doesn't take effect until PoSh loads ... and by then the window is showing. so it shows & then hides. i've seen mention that using VBScript will allow one to suppress that, but i can't find any info on it at the moment. [*blush*] – Lee_Dailey Dec 20 '19 at 01:14
  • AFAIK, you can get around the Start menu issue by creating multiple Windows shortcuts with different arguments, place them in a directory e.g. c:\shortcuts then pin all of them to the start menu – Scepticalist Dec 20 '19 at 05:48
  • 2
    This is a known issue listed under [#3028](https://github.com/PowerShell/PowerShell/issues/3028), the workaround is indeed to use a vbs script as @Lee_Dailey suggests. – iRon Dec 20 '19 at 07:47
  • 2
    A VBScript solution, as suggested by @Lee_Dailey, can be found in this answer: https://stackoverflow.com/a/41229169/45375. A script-less solution via `mshta.exe` can be found in https://stackoverflow.com/a/58064713/45375, but note that it may trigger AV software. – mklement0 Dec 20 '19 at 13:29
  • @Scepticalist I started off with the idea of creating a shortcut to each PuTTY session. This was the setup I had used in Windows 7, however in the latest build of Win10 it doesn't work any more. Win10 appears to resolve any shorcut added to the start menu back to the underlying .exe file, and just treats all shortcuts to the same executable as being one single start menu entry, which is pretty unhelpful. – Incans Dec 26 '19 at 17:32
  • Thanks for the links to the VBA solution. This seems to be a failing in Powerscript, I would have expected command line arguments to be implemented in the startup code of the powershell interpreter before the window was created and the script interpreter started to run, but it seems that's not the way it works. – Incans Dec 26 '19 at 17:34

0 Answers0