OctopusDeploy / Issues

| Public | Bug reports and known issues for Octopus Deploy and all related tools
https://octopus.com
162 stars 20 forks source link

Offline Drop script fails due to incorrect relative paths when run as admin #8973

Closed MJRichardson closed 1 month ago

MJRichardson commented 1 month ago

Severity

Small number of customers. Work-around available.

Version

3.0

Latest Version

I could reproduce the problem in the latest build

What happened?

When running offline drop scripts as an admin, the working folder is set to C:\WINDOWS\system32. This causes the script to fail, due to relative paths.

Reproduction

Error and Stacktrace

No response

More Information

Workaround

https://help.octopus.com/t/offline-package-drop-elevated-permission-issue/3750/2

octoreleasebot commented 1 month ago

Release Note: When running Offline Drop scripts as administrator, the working location is now changed from C:\WINDOWS\system32 to the directory containing the bundle

nfitton commented 1 month ago

Hi there @MJRichardson . This fix assumes the user is running the PS1 script, and doesn't address the bug when running the CMD script. The bug we reported is, that when you right click on the .cmd file and "Run as administrator", windows defaults to running the cmd script in C:\windows\system32 and the .ps1 file does not exist in that directory.

Your fix assumes the ps1 script is executing. But we are not even getting that far because we right click the cmd file and nothing happens. The fix to that problem is to add these two lines to the top of the cmd file, as suggested in our bug report:

@echo off
cd /d %~dp0
MJRichardson commented 1 month ago

@nfitton, I do apologize. You're correct. We tested the change by executing the PowerShell script, which sounds rather foolish now.

I've made the change to the cmd file, which will now roll out.

nfitton commented 1 month ago

No worries @MJRichardson , and thank you for the additional fix! I think both fixes make sense because some users will execute the ps1 directly. It depends on the IT domain policy of our customers.

Octobob commented 4 weeks ago

:tada: The fix for this issue has been released in:

Release stream Release
2024.3 2024.3.11794
2024.4+ all releases
nfitton commented 3 weeks ago

@MJRichardson I tested the latest build and it works perfectly. Thank you!