hack のためのネタ帳, etc,,,

以下、未解決案件

経緯

Windpws 7 Professional
Microsoft Windows
バージョン 6.1 (ビルド 7601: Service Pack 1)
の環境で、PowerShell 2 が入ってる状態。
C:\Users\ほげほげ\Downloads\cygwin>powershell $PSVersionTable

Name                           Value
----                           -----
CLRVersion                     2.0.50727.8762
BuildVersion                   6.1.7601.17514
PSVersion                      2.0
WSManStackVersion              2.0
PSCompatibleVersions           {1.0, 2.0}
SerializationVersion           1.1.0.1
PSRemotingProtocolVersion      2.1
cygwin_autoinstall.bat で Cygwin を入れようとしたところ wget 代わりに用いていた BitsTransfer が以下のようなエラーを吐いて動作せず。
C:\Users\ほげほげ\Desktop\新しいフォルダー>powershell -Command "Import-Module BitsTransfer; Start-BitsTransfer https://gist.github.com/kou1okada/7802343/raw/cygwin_autoinstall.bat"
Start-BitsTransfer : セキュリティで保護されたチャネル サポートでエラーが発生しました
発生場所 行:1 文字:47
+ Import-Module BitsTransfer; Start-BitsTransfer <<<<  https://gist.github.com/kou1okada/7802343/raw/cygwin_autoinstall.bat
    + CategoryInfo          : InvalidOperation: (:) [Start-BitsTransfer]、Exception
    + FullyQualifiedErrorId : StartBitsTransferCOMException,Microsoft.BackgroundIntelligentTransfer.Management.NewBitsTransferCommand
C:\Users\ほげほげ\Desktop\新しいフォルダー>powershell -Command "Import-Module BitsTransfer; Start-BitsTransfer http://example.com/"
Start-BitsTransfer : アクセスが拒否されました。 (HRESULT からの例外: 0x80070005 (E_ACCESSDENIED))
発生場所 行:1 文字:47
+ Import-Module BitsTransfer; Start-BitsTransfer <<<<  http://example.com/
    + CategoryInfo          : NotSpecified: (:) [Start-BitsTransfer]、UnauthorizedAccessException
    + FullyQualifiedErrorId : System.UnauthorizedAccessException,Microsoft.BackgroundIntelligentTransfer.Management.NewBitsTransferCommand
Windows 7 SP1 なので
PowerShell の Version が古いのかと思ったが、
BITS 自体は PowerShell 2.0 からサポートされてる模様
BITS 自体はきちんと呼ばれてるみたいだし、かなり謎な状況。
http/https ともに通らない感じなのだが、よく見ると、http と https では発生している例外が違う。

以下に、Get-BitsTransfer には管理者権限が必要とかあるが、Start-BitsTransper で起こるのが謎
以下で報告されてる https の症状に合致してる気がするんだけど、replay がない orz
こっちはかなり状況が近い。 BITS の制限でうんたらかんたら書いてあるんだけど
この症状引き当てたのはこのマシンが初めてで、
3桁は行かないまでも2桁台のかなり多くのマシンで問題なく動いていたので
このマシン特有の何かの設定が邪魔しているとしか思えない状況。

人のマシンなので、ちょっと試せてないのだが、
BITS' DisableBranchCache group policy を disable にして 90 分待てとか書いてあるので、これなんだろうか???



System.Net.WebClient ならいけそうな気がしたので試してみたところ、
C:\Users\ほげほげ\Downloads\cygwin>powershell -Command "(New-Object System.Net.WebClient).DownloadFile('http://example.com/', 'example%2findx.html')"
C:\Users\ほげほげ\Downloads\cygwin>powershell -Command "(New-Object System.Net.WebClient).DownloadFile('https://google.com/', 'Google%2findx.html')"
となり、お!、これはいけるかも?と思いきや、
C:\Users\ほげほげ\Downloads\cygwin>powershell -Command "(New-Object System.Net.WebClient).DownloadFile('https://gist.github.com/kou1okada/7802343/raw/cygwin_autoinstall.bat', 'cygwin_autoinstall.bat')"
"2" 個の引数を指定して "DownloadFile" を呼び出し中に例外が発生しました: "基礎になる接続が閉じられました: 送信時に、予期しないエラーが発生しました。"
発生場所 行:1 文字:47
+ (New-Object System.Net.WebClient).DownloadFile <<<< ('https://gist.github.com/kou1okada/7802343/raw/cygwin_autoinstall.bat', 'cygwin_autoinstall.bat')
    + CategoryInfo          : NotSpecified: (:) []、MethodInvocationException
    + FullyQualifiedErrorId : DotNetMethodException
のように GitHub だけ通らない罠 orz
何だよこれは

※1 の指摘もあったので、念のため「管理者として実行」した cmd.exe でも試してみたが効果なし。
unauthorized とか言われているので、ExecutionPolicy の件も疑って、-ExecutionPolicy オプション付けて一通り試してみたがこれも外れ。
順調に手詰まり感が高い orz



利用可能な PowerShell の最新版を以下で確認してみたところ Windows 7 は WMF 5.1 (Windows Management Framework 5.1) が最新との事。

という事で、PowerShell 2 がダメと言う線を消すために、WMF 5.1 も入れてみた。
しかし、これは、アーカイブのサイズは大したことないくせに、
インストール時間が地味に長く、数分では終わらない感じ。
イケてない。

しかも、結果は以下のように塩っぱい感じ。
C:\Users\ほげほげ>powershell $PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.14409.1005
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.14409.1005
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
C:\Users\ほげほげ\Downloads\cygwin>powershell -Command "Import-Module BitsTransfer; Start-BitsTransfer https://gist.github.com/kou1okada/7802343/raw/cygwin_autoinstall.bat"
Start-BitsTransfer : セキュリティで保護されたチャネル サポートでエラーが発生しました
At line:1 char:29
+ ... tsTransfer; Start-BitsTransfer https://gist.github.com/kou1okada/7802 ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Start-BitsTransfer], Exception
    + FullyQualifiedErrorId : StartBitsTransferCOMException,Microsoft.BackgroundIntelligentTransfer.Management.NewBitsTransferCommand
C:\Users\ほげほげ\Downloads\cygwin>powershell -Command "(New-Object System.Net.WebClient).DownloadFile('https://gist.github.com/kou1okada/7802343/raw/cygwin_autoinstall.bat', 'cygwin_autoinstall.bat')"
Exception calling "DownloadFile" with "2" argument(s): "要求は中止されました: SSL/TLS のセキュリティで保護されているチャネルを作成できませんでした"
At line:1 char:1
+ (New-Object System.Net.WebClient).DownloadFile('https://gist.github.c ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : WebException



という事で、
駄目だこれ解決出来ん



あと、試せてないのは
BITS' DisableBranchCache group policy を disable にして 90 分待てとかいう件だが、
これなんだろうか???

しかし、手元の Windows 10 は BITS 問題なく動いてて、
$ ls -a /proc/registry/HKEY_LOCAL_MACHINE/SOFTWARE/Policies/Microsoft/Windows/BITS/
.  ..
$ ls -a /proc/registry/HKEY_CURRENT_USER/Software/Policies/Microsoft/Windows/BITS
ls: '/proc/registry/HKEY_CURRENT_USER/Software/Policies/Microsoft/Windows/BITS' にアクセスできません: No such file or directory
と言う状況なので、「By default, the Windows BranchCache feature is enabled.」の状態で問題なく動いているはずなのだが?

コメントをかく


「http://」を含む投稿は禁止されています。

利用規約をご確認のうえご記入下さい

Wiki内検索

フリーエリア

管理人/副管理人のみ編集できます