4
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

コマンドプロンプト(powershell)経由でファイルをダウンロード、実行

Last updated at Posted at 2015-10-15

コマンドプロンプトに以下貼り付け

@powershell -NoProfile -ExecutionPolicy unrestricted -Command "iex ((new-object net.webclient).DownloadString('http://hoge.com/sample.ps1'))"

解説: powershellにて動作

sample.ps1
$url = "http://hoge.com/sample.exe"
if ($env:TEMP -eq $null) {
  $env:TEMP = Join-Path $env:SystemDrive 'temp'
}
$fixTempDir = Join-Path $env:TEMP "ps"
if (![System.IO.Directory]::Exists($fixTempDir)) {[System.IO.Directory]::CreateDirectory($fixTempDir)}
$file = Join-Path $fixTempDir "sample.exe"

function Download-File {
param (
  [string]$url,
  [string]$file
 )
  # Downloading $url to $file
  $downloader = new-object System.Net.WebClient
  $downloader.Proxy.Credentials=[System.Net.CredentialCache]::DefaultNetworkCredentials;
  $downloader.DownloadFile($url, $file)
}

# download the package
Download-File $url $file

# start sample.exe
Start-Process "$file"
4
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?