Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Working fix to stop window auto closing and to allow copy past #10

Open
cameter opened this issue May 5, 2019 · 3 comments
Open

Working fix to stop window auto closing and to allow copy past #10

cameter opened this issue May 5, 2019 · 3 comments

Comments

@cameter
Copy link

cameter commented May 5, 2019

To make file auto exacutable create a registry edit file as follows:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\Open\Command]
@=""C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -noLogo -ExecutionPolicy unrestricted -file "%1""

(create text file. add scrypt to file. change file extension to .reg execute file and click yes to add to registry. .ps1 files can now be run by double clicking them)

To stop windows auto closing just add the following to the end of the scrypt (remove 1st colon):

,# If running in the console, wait for input before closing.
if ($Host.Name -eq "ConsoleHost")
{
Write-Host "Press any key to continue..."
$Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyUp") > $null
}

To stop the progress window getting in the way of copying and pasting add the following:

Write-Progress -Activity "Collecting Episode Data from TheTVDB" -Status "Ready" -Completed

(must be added at the end of the last section as shown in example below)
ForEach ($Show in ($Missing.Keys | Sort-Object)) {
ForEach ($Season in ($Missing[$Show].airedSeason | Sort-Object -Unique)) {
$Episodes = $Missing[$Show] | ? { $_.airedSeason -eq $Season }
ForEach ($Episode in $Episodes) {
"{0} S{1:00}E{2:00} - {3}" -f $Show,[int]$Season,[int]$Episode.airedEpisodeNumber,$Episode.episodeName
}
}
Write-Progress -Activity "Collecting Episode Data from TheTVDB" -Status "Ready" -Completed}

@hirenshah
Copy link

Why not just run the script in Powershell ISE? The results are shown in the console window when the script finishes:

Annotation 2019-07-04 104040

Annotation 2019-07-04 104245

@cameter
Copy link
Author

cameter commented Jul 4, 2019

You can do it that way. I prefer to have it as an auto executable file that way I can just click on it and it will run. Rather than having to open it in power shell and then run it each time I need it. Suppose it depends on how often you use the script and how easy you would like the process

@dawesi
Copy link

dawesi commented Apr 10, 2021

why do you care if it closes? just pipe results to text output as in readme if you want to see output??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants