Skip to content

runspace.ps1 fails comparing versions when running with arguments #325

@Hahubel1

Description

@Hahubel1

Describe the bug
Running runspace.ps1 w/ arguments on a fresh installation w/o winget gives the following output.
====Chris Titus Tech=====
=====Windows Toolbox=====
VERBOSE: Arguments Detected, Running Args
VERBOSE: Installing Microsoft.WindowsTerminal,Git.Git.
WARNING: 10/23/2022 22:01:59 | Warning | Winget is not supported on this version of Windows (Pre-1809). Stopping installs
Thank you for using winutil!

The GUI version runs correctly.

To Reproduce
Steps to reproduce the behavior:

  1. New installation - I used a fresh Win10 sandbox that is still on "2004".
  2. $env:args="Install:Microsoft.WindowsTerminal,Git.Git"
  3. [Net.ServicePointManager]::SecurityProtocol=[Net.SecurityProtocolType]::Tls12;iex(New-Object Net.WebClient).DownloadString('https://raw.githubusercontent.com/ChrisTitusTech/winutil/[main¦test]/runspace.ps1')
  4. See error

Expected behavior
winget shall be installed

Screenshots
.

Additional context
Started ISE / set breakpoint at - if (($sync.ComputerInfo.WindowsVersion) -lt "1809")
The value of $sync.ComputerInfo.WindowsVersion is "2004" and it compares and runs as expected.
Ended debugger and tried once more - issue is still there.
[later]
Could it be asynchronous processing and bad timing? Yes!
Added a "sleep -s 3" just before "if (($sync.ComputerInfo.WindowsVersion) -lt "1809")" and it works fine.
I run it at least 20 times, always sucessful as below.
====Chris Titus Tech=====
=====Windows Toolbox=====
VERBOSE: Arguments Detected, Running Args
VERBOSE: Installing Microsoft.WindowsTerminal,Git.Git.
VERBOSE: 10/23/2022 22:02:43 | INFO | WinGet was not detected
VERBOSE: 10/23/2022 22:02:43 | INFO | Installing WinGet

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions