We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 377a3ef commit a83b36cCopy full SHA for a83b36c
1 file changed
win32/Lib/win32serviceutil.py
@@ -50,8 +50,13 @@ def LocatePythonServiceExe(exe=None):
50
# pywin32 installed it next to win32service.pyd (but we can't run it from there)
51
maybe = os.path.join(os.path.dirname(win32service.__file__), exe)
52
if os.path.exists(maybe):
53
- print(f"copying host exe '{maybe}' -> '{correct}'")
54
- win32api.CopyFile(maybe, correct)
+ print(f"moving host exe '{maybe}' -> '{correct}'")
+ # Handle case where MoveFile() fails. Particularly if destination file
55
+ # has a resource lock and can't be replaced by src file
56
+ try:
57
+ win32api.MoveFileEx(maybe, correct, win32con.MOVEFILE_REPLACE_EXISTING)
58
+ except win32api.error as exc:
59
+ print(f"Failed to move host exe '{exc}'")
60
61
if not os.path.exists(correct):
62
raise error(f"Can't find '{correct}'")
0 commit comments