Как создать и запустить файл сценария power shell в windows 11 или 10

  1. Gotcha#1 – If Notepad++ is already running then when you start a new instance of Notepad++.exe it sees that a copy is already running and will hand control to that. It does not pass along that it was started minimized. Thus Notepad++ will appear to start as a window or maximized if that’s what you already had it as.
  2. Gotcha #2 – If Notepad++ is already running, but minimized, then attempts to start Notepad++ as minimized end up both passing control to the already running copy but also activating it to a normal or maximized window.
  3. Gotcha 3 – There is another “gotcha” where if Notepad++ is running as a maximized window, you exit/close it, and then attempt to start it as minimized that Notepad++ will fire up as maximized.

The only thing works is for you to be running Notepad++ as a non-full screen windowed application, for you to exit/close it, and then to start it as minimized.

The syntax I used from PowerShell was:
Start-Process "C:\npp\npp858x64\notepad++.exe" -WindowStyle Minimized

A normal installation of Notepad++ is usually in the C:\Program Files\Notepad++\notepad++.exe directory meaning people would use:
Start-Process "C:\Program Files\Notepad++\notepad++.exe" -WindowStyle Minimized

Again though, the gotchas mentioned above will apply regardless on if you try to start Notepad++ from Powershell, via a .lnk shortcut file that says “run minimized” or the command prompt’s START command with the /MIN option run run either the exe or shortcut. All of them will fail to be minimized if any of the gotchas I listed above apply.

To start a minimized Notepad++ you must:

  1. Not already have Notepad++.exe running.
  2. That when you exited/closed Notepad++ that it had been a windowed app (not maximized) regardless on if you may have had it minimized at the time you closed it.
    It’s a rather narrow eye-hole in the needle but you can nail it 100% of the time if those two conditions exist.

If you absolutely must start a minimized copy of Notepad++ then I would:

  1. Install a portable copy somewhere.
  2. Rename the portable copy of Notepad++.exe to something else such as min-notepad.exe.
  3. In your powershell script see if the min-notepad.exe process is running and if so, kill it and wait for it to terminate as we will then be updating the config.xml file.
  4. In your powershell script inspect the config.xml file for your portable copy and see if the line for <GUIConfig name="AppPosition" ... has isMaximized="yes". If so, change that to be isMaximized="no" and save it.
  5. Now you can start min-notepad.exe in minimized mode but there is still one more gotcha… You need to start min-notepad.exe with the -multiInst command line option to prevent it from locating a copy of Notepad.exe that is already running and passing control to it. The PowerShell command becomes:
    Start-Process "C:\npp\npp858x64\min-notepad.exe" -ArgumentList @("-multiInst") -WindowStyle Minimized

I have never used NotePad++ before and I am trying to configure the same for editing PowerShell scripts.

:/>  Usb zip что это такое в биосе и как загрузиться с "установочного" двд или флешки

All assistance in downloading the “PS1 plugin for NotePad++” is appreciated.

Notepad++ highlighting is great but not really a requirement for editing anything and if you can’t find the highlighter format for a type you can either go without, use a different app, or build your own/find one another has done.

Notepad++ highlighting is great but not really a requirement for editing anything and if you can’t find the highlighter format for a type you can either go without, use a different app, or build your own/find one another has done.

What I would *really* find useful is auto-indenting that does nesting properly.
Maybe it is because of the way that my mind works, but I find levels of indentation very useful.

I would recommend using the “Windows Powershell ISE” It’s included with Powershell 2.0+ and has all the commands ready for testing and insert/save.

1698696989837.png

I will check it out.
Thank you.

Thanks for pointing this out. I knew about it, once, but it had completely slipped my mind.

I absolutely hate Power Shell syntax, it’s just amazingly verbose and unwieldy, and having an environment such as this that can do dedicated syntax checking and remind you about what that obscure command you use every few years, but only remember part of, actually is and how you write it out is most helpful.

Thanks for pointing this out. I knew about it, once, but it had completely slipped my mind.

Welcome. :)
Ya, it’s a pretty useful tool to have.

Forgot to mention that Visual Studio Code is also an option – and a much more powerful one to use, albeit much more complex.. Powershell ISE is like a Notepad lovechild more fitting to the Notepad++’ish of the OP.

:/>  Средства диагностики компьютера на борту Live-диска Сергея Стрельца

Welcome. :)
Ya, it’s a pretty useful tool to have.

Forgot to mention that Visual Studio Code is also an option – and a much more powerful one to use, albeit much more complex.. Powershell ISE is like a Notepad lovechild more fitting to the Notepad++’ish of the OP.

Correct, the NP++ is more suited to my requirements.

PowerShell ISE is probably the best bet, but you can set the language in notepad++ to PowerShell and it’ll do the syntax highlighting which may help you.

PowerShell ISE is probably the best bet, but you can set the language in notepad++ to PowerShell and it’ll do the syntax highlighting which may help you.

How is automatic (or semi-automatic) indenting work?

How is automatic (or semi-automatic) indenting work?

No idea, I dont really write many PowerShell scripts, i just know the language option is there. I also tend to indent myself when programming anything, its just a habit i got in to.

I have never used NotePad++ before and I am trying to configure the same for editing PowerShell scripts.

All assistance in downloading the “PS1 plugin for NotePad++” is appreciated.

use this instead

code.visualstudio.com


Visual Studio Code – Code Editing. Redefined

Visual Studio Code is a code editor redefined and optimized for building and debugging modern web and cloud applications. Visual Studio Code is free and available on your favorite platform – Linux, macOS, and Windows.

use this instead

code.visualstudio.com


Visual Studio Code – Code Editing. Redefined

Visual Studio Code is a code editor redefined and optimized for building and debugging modern web and cloud applications. Visual Studio Code is free and available on your favorite platform – Linux, macOS, and Windows.

I must be really behind in the news.
Back in the day when one of my gigs was programming in Visual Foxpro, wasn’t Visual Studio a paid product and now it appears to be free?

:/>  Без доступа к интернету защищено

BTW – Thank you for the link.

I must be really behind in the news.
Back in the day when one of my gigs was programming in Visual Foxpro, wasn’t Visual Studio a paid product and now it appears to be free?

BTW – Thank you for the link.

yeah Visual Studio was a whole object-oriented application development thing. VSCode is just for writing code. Its like the included ISE but on steroids.

I love PowerShell ISE but keep in mind it’s effectively discontinued. No longer in active development and will not support beyond PowerShell 5.1 which goes EoL in just over 3 years.

VSCode is the officially supported editor for PowerShell 7 onwards. It’s also good editor for C++, C#, Python, PHP and many more.

Оставьте комментарий