Skip to content

Perform file move of pythonservice.exe during install#2251

Merged
mhammond merged 2 commits into
mhammond:mainfrom
JacobNolan1:main
Aug 6, 2024
Merged

Perform file move of pythonservice.exe during install#2251
mhammond merged 2 commits into
mhammond:mainfrom
JacobNolan1:main

Conversation

@JacobNolan1
Copy link
Copy Markdown
Contributor

During install perform move of pythonservice.exe instead of file copy to handle .exe always being present in src location.

Additional try-except added to handle continuation of program if fileMove fails.

@JacobNolan1
Copy link
Copy Markdown
Contributor Author

Attempted a build to test this, but wasn't successful. Was missing a couple dlls and haven't managed to track down why I don't have them yet.

@mhammond
Copy link
Copy Markdown
Owner

Thanks - note if you go to "checks" and dig around you can find artifacts for your PR - in this case it is at https://github.com/mhammond/pywin32/actions/runs/8890105083?pr=2251

@JacobNolan1
Copy link
Copy Markdown
Contributor Author

Awesome thanks Mark. This sorted my issue. I may change the exception output "Failed to move host exe" in the case where the file already exists, it did deceive me for a moment there thinking the process failed completely.

The current error output from MoveFile is "Cannot create a file when file already exists". So I think in this case, where the destination file is still used, MoveFile does fail to replace. Which makes sense.

The install does work regardless if pythonservice.exe is present in the destination dir.

@mhammond
Copy link
Copy Markdown
Owner

mhammond commented May 2, 2024

It's important that the move replace the file - if the source file exists it implies pywin32 has been upgraded so the existing target may not work. MoveFileEx should offer the semantics you needs.

Comment thread win32/Lib/win32serviceutil.py Outdated
JacobNolan1 and others added 2 commits August 6, 2024 12:15
… exists at src

During install perform move of pythonservice.exe instead of file copy to handle .exe always being present in src location. 

Additional try-except added to handle continuation of program if fileMove fails.
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

Successfully merging this pull request may close these issues.

2 participants