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

[BUG]: Win 11 "takeown /d y" parameter is language dependent #149

Closed
arman-ku opened this issue Jun 27, 2022 · 2 comments
Closed

[BUG]: Win 11 "takeown /d y" parameter is language dependent #149

arman-ku opened this issue Jun 27, 2022 · 2 comments
Labels
bug Something isn't working

Comments

@arman-ku
Copy link

arman-ku commented Jun 27, 2022

win 11 10.0.22000.778

some options use takeown with /d y parameters. The y is language dependent however.
For example, i installed a german build, so the "y" would be a "j" for "ja".

Code example:

:: ----------------------------------------------------------
:: ----------------Clear main telemetry file-----------------
:: ----------------------------------------------------------
echo --- Clear main telemetry file
if exist "%ProgramData%\Microsoft\Diagnosis\ETLLogs\AutoLogger\AutoLogger-Diagtrack-Listener.etl" (
takeown /f "%ProgramData%\Microsoft\Diagnosis\ETLLogs\AutoLogger\AutoLogger-Diagtrack-Listener.etl" /r /d y
icacls "%ProgramData%\Microsoft\Diagnosis\ETLLogs\AutoLogger\AutoLogger-Diagtrack-Listener.etl" /grant administrators:F /t
echo "" > "%ProgramData%\Microsoft\Diagnosis\ETLLogs\AutoLogger\AutoLogger-Diagtrack-Listener.etl"
echo Clear successful: "%ProgramData%\Microsoft\Diagnosis\ETLLogs\AutoLogger\AutoLogger-Diagtrack-Listener.etl"
) else (
echo "Main telemetry file does not exist. Good!"
)

will throw:

Error: Invalid syntax. The 'y' value cannot be used for the '/d' option.

@arman-ku arman-ku added the bug Something isn't working label Jun 27, 2022
@undergroundwires
Copy link
Owner

Thank you @arman-ku. I can reproduce this on german versions of Windows.

Since this issue was raised (around the 0.12.X releases), I've already removed most instances of takeown commands, including the script you shared.However, there's still one remaining usage.

Here's a summary of the options considered:

  • ❌ Enumerating all languages for their "yes" equivalents. Yes and No in many languages list list is too extensive and impractical 🙂
  • ❌ Setting the current culture before executing ([Threading.Thread]::CurrentThread.CurrentCulture). This doesn't work.
  • ❌ Leveraging the side-effect of the copy command output to determine the "yes" equivalent, as suggested in this ServerFault post. While reliable, it's overly complex.
  • ❌ Parsing the takeown /? help documentation. This approach proved unreliable as the documentation doesn't always accurately reflect command variations due to incomplete i18n translations.
  • ✅ Use choice Windows utility to get available choices and return the first item. Tested on English: (Y) and German (J).

The most effective solution I found is to use the choice Windows command, which reliably determines the current language's equivalent for "yes". This approach has been tested successfully in both English (Y) and German (J).

I'm planning to implement this solution using the choice command in the upcoming patches.

undergroundwires added a commit that referenced this issue Dec 30, 2023
This commit addresses the language dependency of the `takeown /d y`
command in non-English Windows versions by using the `choice` utility.
This utility dynamically determines the equivalent of 'yes' in the
current system language, resolving issues encountered in the delete
script.

Other solution options such as enumerating language equivalents,
adjusting script culture settings, using side-effects of the `copy`
command, and parsing `takeown` help documentation proved either
impractical or unreliable.

The `choice` command has been successfully tested in both English and
German environments, ensuring reliable execution across various locales.
This change replaces the previous `takeown` usage in the script,
its reliability across diverse Windows locales.
undergroundwires added a commit that referenced this issue Dec 30, 2023
This commit addresses the language dependency of the `takeown /d y`
command in non-English Windows versions by using the `choice` utility.
This utility dynamically determines the equivalent of 'yes' in the
current system language, resolving issues encountered in the delete
script.

Other solution options such as enumerating language equivalents,
adjusting script culture settings, using side-effects of the `copy`
command, and parsing `takeown` help documentation proved either
impractical or unreliable.

The `choice` command has been successfully tested in both English and
German environments, ensuring reliable execution across various locales.
This change replaces the previous `takeown` usage in the script,
its reliability across diverse Windows locales.
@undergroundwires
Copy link
Owner

The fix is released in 0.12.10 🚀.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants