$cmdline = [System.Environment]::CommandLine $index = $cmdline.IndexOf("--") echo $cmdline $cmdline = $cmdline.SubString($index + 2).Trim() $dir = Split-Path -Parent $MyInvocation.MyCommand.Definition $env:path="$dir;$env:path" Add-Type -TypeDefinition (Get-Content $dir\progress.cs -raw) -ReferencedAssemblies System.Windows.Forms,System.Drawing,System.Runtime $wnd = New-Object Progress($cmdline) $wnd.Run()