ThioJoe / Windows-Super-God-Mode

Creates shortcuts to virtually every special location or action built into Windows
GNU General Public License v3.0
1.38k stars 97 forks source link

use 'start' for autoclose the cmd-prompt #3

Closed zedd-0 closed 2 weeks ago

zedd-0 commented 2 weeks ago

you should use "start" in your bat/cmd file, so the script will not stop and closes:

start "" PowerShell.exe -NoProfile -ExecutionPolicy Bypass -File "Super_God_Mode.ps1"

you should always use "start" with title quotation marks, so it will not confused by other quotation marks as a title.

maybe you should use .cmd instead of .bat. it's not that important, but .bat could theoretically run in DOS environments, while .cmd only runs on Windows NT environments, just to be 101% sure. ;-)

i see a second black window, from yout powershell-script: "Use the GUI window that just appeared to select any options and run the script."

is the info really necessary? can't this be integrated into the GUI? just one window looks better and doesn't confuse people. (personal opinion)

ThioJoe commented 2 weeks ago

Hm I'll look into it, but the command prompt window actually does serve a purpose in that script uses Write-Host to print out all the info as it happens, and the summary at the end. The GUI Window is just meant to be a convenient way to set the initial launch arguments for the script.

Basically the script launches the GUI, so by the time the GUI launches the script is already running in the cmd window. Then when the user hits Run Script it just sets the conditions for the script to continue in the powershell window. So it's not like the cmd window is 'extra' or something.

RokeJulianLockhart commented 2 weeks ago

https://github.com/ThioJoe/Windows-Super-God-Mode/issues/3#issuecomment-2307962281

@ThioJoe, isn't Write-Host deprecated (in favour of Write-Output or Write-Information)? You might want to see https://github.com/RokeJulianLockhart/PowerShell-Docs/blob/750aa899bb0167a01753af052e6b9f778f52b28e/reference/7.4/Microsoft.PowerShell.Utility/Write-Host.md?plain=1#L38-L40:~:text=Starting%20in%20Windows%20PowerShell%205.0%2C%20%60Write%2DHost%60%20is%20a%20wrapper%20for%20%60Write%2DInformation%60.

ThioJoe commented 2 weeks ago

Closing this since it's not actually applicable (I didn't fully understand the original point at first). When you said "i see a second black window, from your powershell-script", that window is not actually a second window to the script, that is the script. So in other words like I touched on before, the GUI is extra and separate, spawned by the script which lives in the console window. So using 'start' would not make a difference, the GUI is not the main thing, the console window is.

It's also why closing the console window also closes the GUI, because again it is the script.