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

Weird console window while starting #333

Closed
leo-liar opened this issue Jun 28, 2024 · 6 comments
Closed

Weird console window while starting #333

leo-liar opened this issue Jun 28, 2024 · 6 comments

Comments

@leo-liar
Copy link

leo-liar commented Jun 28, 2024

Hello,

with version 5.55 there is now a console window visible every time PersistentWindows is started because (apparently) it starts, waits a few seconds and then creates some file pw_restart.cmd, terminates itself and executes said cmd file. Is this intentional?

(I'm using a shortcut to PersistentWindows.exe in my auto start menu.)

Also said cmd file prepends another command line parameter (-wait_taskbar) before all those configurations I've included in the start menu link to PersistentWindows.exe.

I don't see any information regarding this behaviour or this new command line parameter in the changelog and I'm not quite understanding the relevant(?) code.

@kangyu-california
Copy link
Owner

kangyu-california commented Jun 28, 2024

The restart behavior was added to enhance the -delay_start command implementation, when trying to address user need in #332.

The -delay_start command option was mainly used to solve PW startup failure, for example PW icon may disappear from taskbar if started too early. The command option is obsolete now as I thought no user is actually using it since newer PW release is able to detect the startup failure by checking taskbar readiness and restart PW if taskbar is not ready.

Restart PW would be a nice addition to -delay_start to make sure PW auto start works reliably.

@leo-liar
Copy link
Author

Ah, I see. If the restart ability is needed, may I propose to use a VBScript file to call pw_restart.cmd so that the console is hidden, e.g. something like this: (source)

If WScript.Arguments.Count >= 1 Then
    ReDim arr(WScript.Arguments.Count-1)
    For i = 0 To WScript.Arguments.Count-1
        Arg = WScript.Arguments(i)
        If InStr(Arg, " ") > 0 or InStr(Arg, "&") > 0 Then Arg = chr(34) & Arg & chr(34)
      arr(i) = Arg
    Next

    RunCmd = Join(arr)
    CreateObject("Wscript.Shell").Run RunCmd, 0 , True
End If

See attached Noshell.vbs which I grabbed from WinPython. (Had to append .txt as extension, otherwise the upload wasn't allowed.)

@kangyu-california
Copy link
Owner

Instead of running PW with -delay_start, you may try a new method to create delayed task using DOS schtasks command, as the result of discussion in #332

schtasks /create /delay 0000:10 /sc onlogon /tn "StartPersistentWindows" /f /tr "'%~dp0pw.bat'" /rl HIGHEST

the /delay 0000:10 command option specifies 10 second delay before running pw.bat (for more details on pw.bat, please refer to README page)

@leo-liar
Copy link
Author

Thanks for suggestion! Maybe I'll give it a try without the -delay_start parameter and just check if this works. (I was just using this since the beginning.)

Your proposal to create a scheduled task sounds okay, but firstly I'm using PersistentWindows on my work laptop where I'm not having admin rights and do want to not clobber the scheduled task menu (personal preference). Secondly this way is rather complicated (manually creating an pw.bat file and then said scheduled task). And thirdly I think you missed my point – meaning that it's just confusing and unexpected to suddenly have a 10s console window popping up where there previously was none. That's why I recommended to automatically hide this (e.g. via VBScript) if there's no better way to do this programmatically.

For now my workaround is to directly start pw_restart.cmd using the Noshell script which prevents the (for me at least) annoying console window.

@kangyu-california
Copy link
Owner

kangyu-california commented Jul 1, 2024

release 5.56 reduced console window waiting time from 10 seconds to 2 seconds. Hope you are satisfied with this improvement.
Please bear in mind -delay_start is an obsolete command option and no longer officially supported.

@leo-liar
Copy link
Author

leo-liar commented Jul 1, 2024

Hello and thanks for the update. Though I still haven't got my point across: A desktop application should (IMHO) not suddenly pop out console windows! (Doesn't matter if it's 2s or 10s.)

That being said I failed to properly understand that -delay_start has been deprecated. Sorry for that, I absolutely missed this change (From Feb 6!) Therefore I've removed the obsolete command line option and PersistentWindows doesn't show up any console windows as expected.

As it's been obsolete for quite some time please don't put any effort into a workaround. I think this issue can be closed.

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

2 participants