Skip to content

Scripts

Scover edited this page Nov 1, 2023 · 13 revisions

Scripts

What are scripts?

Scripts are individual, interchangeable snippets of Batch, PowerShell or Regedit script code associated with metadata. They can be executed to debloat, optimize or maintain the system in a simple and unique way.

Scripts can be scheduled for execution from WinClean's interface.

Storage

Script code and metadata are stored in XML files. WinClean deserializes them. Here's the expected XML structure:

<?xml version="1.0" encoding="UTF-8"?>
<Script>
  <Name>EnglishName</Name>
  <Name xml:lang="fr">FrenchName</Name>
  <Description>EnglishDescription</Description>
  <Description xml:lang="fr">FrenchDescription</Description>
  <Category>Maintenance/Debloating/Customization</Category>
  <Recommended>Safe/Dangerous/Limited</Recommended>
  <Impact>Ergonomics/Free storage space/Memory usage/Network usage/Privacy/Performance/Shutdown time/Startup time/Storage speed/Visuals</Impact>
  <Versions>>=10.0.0</Versions> <!-- Supported Windows version range in SemVer 2.0.0 standard range syntax (optional). If unspecified, the script considered to support all Windows versions. -->
  <Code>
    <Execute Host="Cmd/PowerShell/Regedit">code</Execute>
    <Enable Host="Cmd/PowerShell/Regedit">code</Enable>
    <Disable Host="Cmd/PowerShell/Regedit">code</Disable>
    <Detect Host="Cmd/PowerShell/Regedit">code</Detect> <!-- Optional -->
    <!-- Either Execute or Enable+Disable -->
  </Code>
</Script>
  • Element order doesn't matter.
  • Element names care case sensitive.
  • Unrecognized elements will be ignored.
  • Values are case insensitive. powershell, PowerShell or POWERSHELL are all valid.

The expected encoding is UTF-8. The expected value of the xml:lang attribute is a BCP-47 language tag.

Effective capability detection

The code in Detect is used to detect the capability that was last executed by the script. Detection is based on the exit code of the host process.

Exit code Recognized effective capacity
0 Disable
1 Enable
2 Execute
3 Detect
other none

Choosing the appropriate host

PowerShell

PowerShell is a very powerful language, however the intepreter may take significant time to launch (several seconds on low-end systems). Best suited for complex operations.

Cmd

While Batch offers less features than PowerShell, the console initializes quicker and can therefore be used for simpler scripts that execute in a few seconds or less.

Regedit

Use it for scripts that only perform configuration changes. It's not an actual scripting language, but rather a list of registry entries. It executes almost instantly.

External code reuse

The codes for some scripts have not been written by the owner of this repository. When this is the case, and when a license is available, links to the original source code and to its associated license are included as comments, either in said source code or at the beginning of the file.