Redirect to "NUL" failed: FileStream will not open Win32 devices

I am trying to remove some verbosity from a command choco installin AppVeyor. Here is what I tried (as suggested here ):

if (Test-Path "C:/ProgramData/chocolatey/bin/swig.exe") {
    echo "using swig from cache"
} else {
    choco install swig > NUL
}

However, this fails:

Redirection to 'NUL' failed: FileStream will not open Win32 devices such as
disk partitions and tape drives. Avoid use of "\\.\" in the path.
At line:4 char:5
+     choco install swig > NUL
+     ~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : RedirectionFailed

Command executed with exception: Redirection to 'NUL' failed: FileStream will not open Win32 devices such as disk partitions and tape drives. Avoid use of "\\.\" in the path.

So my question is how to suppress verbosity of a command choco installin PowerShell on AppVeyor?

+4
source share
1 answer

nul- batch syntax. In PowerShell, you can use $nullinstead, as Matthias R. Jessen pointed out in his comment:

choco install swig > $null

Out-Null, void:

choco install swig | Out-Null
$dummy = choco install swig
[void](choco install swig)
+6

Source: https://habr.com/ru/post/1622203/


All Articles