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

"Start at login" produces error for standalone executable on Windows 10 #135

Closed
bwbug opened this issue Feb 8, 2023 · 6 comments
Closed

Comments

@bwbug
Copy link

bwbug commented Feb 8, 2023

When selecting the "Start at login" option in the systray icon produced by a standalone executable compiled for Windows 10 produces the error message Windows cannot find C:\Program`.

The .cmd file in the startup folder contains the following command [slightly redacted]:

start C:\Program Executables\Email-OAuth2-Proxy\dist\emailproxy.exe C:\Users\username\AppData\Local\Temp\_MEI134122\emailproxy.py

I believe I can fix the error by making the first argument C:\progra~4\Email-OAuth2-Proxy\dist\emailproxy.exe, or perhaps by enclosing it in double-quotation marks, but perhaps it would make sense to check for spaces in the path when generating the expression.

Would you mind explaining the reason/purpose for the second argument (C:\Users\username\AppData\Local\Temp\_MEI134122\emailproxy.py)? Can this be omitted if I want to set up my own startup script?

@simonrob
Copy link
Owner

simonrob commented Feb 8, 2023

Thanks for reporting this. There are two issues here – firstly, the lack of consideration of spaces in file paths when using the Start at login option. Start at login is a bit of a bonus feature, and actually surprisingly hard to get right on all platforms. c1a78de fixes this, though it may well be possible to carefully craft file names or other parameters to break it. The assumption here is that users of the proxy won't try to break their own systems. I don't actually have access to Windows to test this, but it should work.

The second issue is that the script should not try to include its own path when packaged via PyInstaller, as this is built into the executable. This is also fixed in c1a78de.

@bwbug
Copy link
Author

bwbug commented Feb 8, 2023

Thank you. What is the purpose of the C:\Users\username\AppData\Local\Temp\_MEI134122\emailproxy.py argument that appeared in the .cmd file? Should the correct contents of the .cmd file not be just the following (for the stand-alone executable)?

start "C:\Program Executables\Email-OAuth2-Proxy\dist\emailproxy.exe"

In any case, I will try the new release in Windows and report back.

@simonrob
Copy link
Owner

simonrob commented Feb 8, 2023

Yes - that's the second fix mentioned above. In normal mode (without PyInstaller) this is the path to the proxy script, but that is not needed when compiled into a single file.

@simonrob
Copy link
Owner

I'm going to close this issue since from my own testing this has been resolved. Feel free to reopen if that is not the case for you.

@bwbug
Copy link
Author

bwbug commented Jun 27, 2023

Hello again. I just updated and recompiled everything, and now the contents of the .cmd file in the Windows startup folder look like this [slightly redacted]:

start "" "C:\Program Executables\Email-OAuth2-Proxy\dist\emailproxy.exe" --cache-store "C:\Program Executables\Email-OAuth2-Proxy\dist\mytokens.dat"

I don't know all variations of the start command, but to me, the initial pair of double quotes ("") look out of place. Nonetheless, executing the .cmd file does start the proxy.

@simonrob
Copy link
Owner

Thanks for checking. The initial pair of double quotes is intended - it's for specifying the title of the command prompt window, but because it is running in windowless mode no title is needed (though the quotes are still mandatory).

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