728x90
http 링크된 파일 다운로드 후 파일명에 버전 정보 추가하는 스크립트 (PowerShell 2.0 기준)
이렇게 만들고 보니 웹브라우저 띄우지 않고 버전 확인까지 가능해서 개이득
한결 편해졌다
$source = "http://~~~test.exe" $destination = "c:\~~~\test.exe" $client = new-object System.Net.WebClient $client.DownloadFile($source, $destination) $version = (Get-Item $destination).VersionInfo.FileVersion Rename-Item $destination test_$version.exe
+ 추가) 로컬에 설치된 버전과 비교하기
$source = "http://~~~test.exe"
$setupname = "setup.exe"
$curruntDir = Split-Path -Parent $MyInvocation.MyCommand.Path
$Destination = "$curruntDir\$setupname"
$client = new-object System.Net.WebClient
$client.DownloadFile($source, $Destination)
$version = (Get-Item $Destination).VersionInfo.FileVersion
# option : [0] -> first line
$LocalVersion = (Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Where-Object {$_.DisplayName -eq 'Test App'}).DisplayVersion[0]
IF ($version -le $LocalVersion)
{
"download file is old or same version"
Remove-Item $Destination
}
ELSE
{
"run upgrade!!"
}
728x90
'Windows' 카테고리의 다른 글
| [ps] 윈도우10 표시 언어 변경 (0) | 2015.12.07 |
|---|---|
| 블루스크린 대처 (0) | 2015.06.26 |
| [Windows] *.ps1 스크립트 실행하기 (0) | 2015.05.28 |
| [Windows] 프로그램 제거 또는 변경에서 강제로 삭제하기 (0) | 2014.10.30 |
| [Windows] 프로그램 설치/삭제 자동화 (0) | 2014.10.20 |