getArguments method

List<String> getArguments()

On windows the powershell is required to acquire elevated privileges.

Implementation

List<String> getArguments() {
  if (runAsAdministrator) {
    return Platform.isWindows
        ? [
            "-Command",
            """
            # Set variables
            \$targetFolder = "${workingDirectory ?? "./"}"
            \$command = "$program"
            \$arguments = "${this.arguments.join(" ")}"

            # Relaunch as administrator
            Start-Process powershell -Verb runAs -wait -ArgumentList @(
                "-NoProfile",
                "-ExecutionPolicy Bypass",
                "-Command `"Set-Location -Path '\$targetFolder'; & '\$command' \$arguments`""
            )

            New-Item -ItemType File -Path "${_processFile.path}"
            """,
          ]
        : [this.program] + this.arguments;
  }
  return this.arguments;
}