Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redirection to 'NUL' failed: FileStream will not open Win32 devices

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

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

However it fails with:

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 there a way to suppress the verbosity of a choco install command within PowerShell on AppVeyor?

like image 359
malat Avatar asked Dec 30 '15 11:12

malat


1 Answers

nul is batch syntax. In PowerShell you can use $null instead, as Mathias R. Jessen pointed out in his comment:

choco install swig > $null

Other options are piping into the Out-Null cmdlet, collecting the output in a variable, or casting it to void:

choco install swig | Out-Null
$dummy = choco install swig
[void](choco install swig)
like image 135
Ansgar Wiechers Avatar answered Nov 15 '22 03:11

Ansgar Wiechers