Skip to content

Encoding mismatch on Windows Task Scheduler XML file #179

@guimlherme

Description

@guimlherme

Current Behavior

On the file App.xaml.cs, the RunOnStartup function creates a task in the Windows Task Scheduler via an XML file. The file header suggests that it is encoded in UTF-16.

@"<?xml version=""1.0"" encoding=""UTF-16""?>

But afterwards, the file is created using File.WriteAllText without an encoding specifier, which defaults to UTF-8

File.WriteAllText(tempXmlFile, taskXml);

This is a problem when Path contains a character with different representations in the two encodings, resulting in an invalid task on the scheduler.

Expected Behavior

The task on the Windows Task Scheduler should have the correct path, even if it has special characters.
My guess is that it should be solved when the correct encoding is passed to File.WriteAllText

File.WriteAllText(tempXmlFile, taskXml, Encoding.Unicode);

Steps to Reproduce

  1. Install the program in a folder that has a special character in the Path (e.g. "C:\Users\User\Utilitários\WinMemoryCleaner.exe")
  2. Activate the Run on Startup function in the program
  3. The task on Windows Task Scheduler will have a corrupted path (e.g. "C:\Users\User\Utilitários\WinMemoryCleaner.exe")

App Version

3.0.8

Windows Version

Windows 11

Additional Context

No response

Checklist

  • I have searched the existing issues to make sure this bug has not been reported yet.
  • I have tested with the latest version of the application.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working as expected or is broken.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions