SE업무/Script 및 코드

PC 포맷 후 필요 프로그램 다운, 설치 파워쉘 스크립트

에륜 2023. 2. 18. 22:28
반응형

포맷할때마다 필요프로그램을 찾고

홈페이지에서 클릭하고 다운받고 설치하는게 귀찮아서 한번 만들어 봤다.

윈도우 파워쉘을 이용하는것이다.

 

기본적인 구성은 설치파일을 다운받고 실행하는것이다.

 

1. 무조건 최신버전을 받을것

2. 최대한 인터페이스를 노출하지 않고 설치할것

을 목표로 제작했다.

 

1번의 경우 꽤나 많이 지원됐지만 코드상 구현이 힘든게많은건 그냥 PASS하고 웹페이지를 뛰우도록했다.

 

링크를 확인하는 방법은 간단하다

클릭시 exe 파일을 받는 링크를 우측클릭후 링크주소 복사 하면된다.

"https://kr.bandisoft.com/bandizip/dl.php?x64"

최신버전 다운로드 링크가 없고 항상 해당 버전명을 링크에 넣을경우에는 살짝식 수정이 필요하다.

 

2번이 불가능한것들이 꽤 있지만 일단 다운이라도 자동으로 받도록 했다.

설치 파일들이 다운되는곳은 C:\temp 폴더이다

mkdir C:\temp
cd C:\temp
####################다운로드 부분####################
#반디집
wget -uri https://kr.bandisoft.com/bandizip/dl.php?x64 -OutFile bandizip.exe
#꿀뷰
wget -uri https://kr.bandisoft.com/honeyview/dl.php?web-kr -OutFile honeyview.exe
#디스코드
wget -uri "https://discord.com/api/downloads/distributions/app/installers/latest?channel=stable&platform=win&arch=x86" -OutFile discord.exe
#팟플레이어
wget -uri https://t1.kakaocdn.net/potplayer/PotPlayer/Version/Latest/PotPlayerSetup64.exe -OutFile PotPlayerSetup64.exe
#노트패드++
$href = ((Invoke-WebRequest -Uri 'https://notepad-plus-plus.org/downloads/').Links | Where-Object { $_.innerText -match 'current version' }).href
$downloadUrl = ((Invoke-WebRequest "https://notepad-plus-plus.org/$href").Links | Where-Object { $_.innerHTML -match 'installer' -and $_.href -match 'x64.exe' }).href
Invoke-RestMethod $downloadUrl -OutFile "np.exe"
#TimeSync
$downloadUrl = ((Invoke-WebRequest "https://www.speed-soft.de/software/time_sync/details/download.php?language=en").Links | Where-Object { $_.innerHTML -match 'Download' -and $_.href -match '.exe' }).href
Invoke-RestMethod "https://www.speed-soft.de/$downloadUrl" -OutFile "sync.exe"
#parsec
wget -uri https://builds.parsec.app/package/parsec-windows.exe -OutFile parsec.exe
#카카오톡
wget -uri https://app-pc.kakaocdn.net/talk/win32/KakaoTalk_Setup.exe -OutFile KakaoTalk_Setup.exe
#스팀
wget -uri https://cdn.akamai.steamstatic.com/client/installer/SteamSetup.exe -OutFile SteamSetup.exe
#블리자드 배틀넷
wget -uri "https://www.battle.net/download/getInstallerForGame?os=win&gameProgram=BATTLENET_APP&version=Live" -OutFile bnet.exe
#텔레그램
wget -uri https://telegram.org/dl/desktop/win64 -OutFile telegram.exe
#whale
wget -uri https://installer-whale.pstatic.net/downloads/installers/WhaleSetup.exe -OutFile whale.exe
#nvidia broadcast
$downloadUrl = ((Invoke-WebRequest "https://www.nvidia.com/ko-kr/geforce/broadcasting/broadcast-app/").Links | Where-Object { $_.innerHTML -match '지금 다운로드하기' -and $_.href -match '.exe' }).href
Invoke-RestMethod $downloadUrl.GetValue(0) -OutFile "nvdiabroadcast.exe"
#nvidia 그래픽드라이버
$downloadUrl = ((Invoke-WebRequest "https://www.nvidia.com/ko-kr/geforce/drivers/").Links | Where-Object { $_.innerHTML -match '지금 다운로드' -and $_.href -match '.exe' }).href
Invoke-RestMethod $downloadUrl -OutFile "nvdia.exe"
#VScode
wget -uri "https://code.visualstudio.com/sha/download?build=stable&os=win32-x64-user" -OutFile vscode.exe


####################실행 부분####################
#반디집
Start-Process -Wait -FilePath "C:\temp\bandizip.exe" -ArgumentList "/S" -PassThru
#꿀뷰
Start-Process -Wait -FilePath "C:\temp\honeyview.exe" -ArgumentList "/S" -PassThru
#디스코드
Start-Process -Wait -FilePath "C:\temp\discord.exe" -ArgumentList "/S" -PassThru
#팟플레이어
Start-Process -Wait -FilePath "C:\temp\PotPlayerSetup64.exe" -ArgumentList "/S" -PassThru
#노트패드++
start-process -Wait -FilePath "C:\temp\np.exe" -ArgumentList '/S' -PassThru
#TimeSync
start-process -Wait -FilePath "C:\temp\sync.exe" -ArgumentList '/S' -PassThru
#parsec
Start-Process -Wait -FilePath "C:\temp\parsec.exe" -ArgumentList "/S" -PassThru
#카카오톡
Start-Process -Wait -FilePath "C:\temp\KakaoTalk_Setup.exe" -ArgumentList "/S" -PassThru
#스팀
Start-Process -Wait -FilePath "C:\temp\SteamSetup.exe" -ArgumentList "/S" -PassThru
#블리자드 배틀넷
Start-Process -FilePath "C:\temp\bnet.exe" -ArgumentList "/S" -PassThru
#텔레그램
Start-Process -Wait -FilePath "C:\temp\telegram.exe" -ArgumentList "/S" -PassThru
#whale
Start-Process -Wait -FilePath "C:\temp\whale.exe" -ArgumentList "/S" -PassThru
#nvidia broadcast
start-process -Wait -FilePath "C:\temp\nvdiabroadcast.exe" -ArgumentList '/S' -PassThru
#nvidia 그래픽드라이버
start-process -Wait -FilePath "C:\temp\nvdia.exe" -ArgumentList '/S' -PassThru
#VScode
Start-Process -Wait -FilePath "C:\temp\vscode.exe" -ArgumentList "/S" -PassThru


####################웹페이지 접근####################
#qbittorrent
$downloadUrl = ((Invoke-WebRequest "https://www.fosshub.com/qBittorrent.html").Links | Where-Object { $_.href -match 'x64_setup.exe' }).href
Start-Process $downloadUrl.GetValue(0)
Start-Sleep -Seconds 5
#CPU-Z,tabby,eartrumpet 다운로드 페이지 접근
Start-Process "https://www.cpuid.com/softwares/cpu-z.html"
Start-Sleep -Seconds 3
Start-Process "https://www.cpuid.com/softwares/hwmonitor-pro.html"
Start-Sleep -Seconds 3
Start-Process "https://github.com/Eugeny/tabby/releases"
Start-Sleep -Seconds 3
Start-Process "https://eartrumpet.app/"

바로 최신버전을 못 찾을 경우 몇가지 변수를 추가해서 얻는 과정이 필요하다..

이 과정은 살짝의 노가다가 필요하지만 내 코드를 보고 참고하면 될듯하다

나도 인터넷에서 찾아오면서 조합한 코드들이다.

 

엔비디아는 다운할때 경고가 뜨는데 예스 해주자!

카카오톡과 스팀은 설치 파일명 유지가 꼭 필요하다.

실행시 기존에 프로그램이 실행중인지 확인하는데 설치파일명이 아닌 다른걸로 실행중이면 설치가 불가능 하다 ㅡㅡ

중간에 다른 설치파일도 그런 경고문이 뜨긴하는데 설치가 가능하니 그냥 쓰셔도 괜찮다.

블리자드 배틀넷는 설치 후 딜레이가 너무길어서 -wait 옵션을 뺐다.

 

Start-process의 옵션을 설명하자면

wait는 설치를 기다리는 것이고 -ArgumentList '/S' -PassThru 는 인터페이스 팝업없이 설치가 가능하다면 설치하도록 하는 옵션이다.

 

실행시는 모두 관리자 권한으로 실행하자!

만약 스크립트파일로 저장해서 실행했는데 아래와 같이 실행이 안된다면

스크립트 실행이 막힌 상태라고 볼 수 있다.

간단히 설정후 사용하자.

 

ExecutionPolicy
Set-ExecutionPolicy Unrestricted

 

위 코드들을 이용하고 수정하여서 내가 원하는 파일도 다운 받으면서 커스텀하면 된다.

아래는 VM에서 테스트하면서 촬영하였다.

 

23.03.01. 추가 혹시나 필요할까봐 파워쉘 스크립트도 업로드하였습니다.

init.ps1
0.00MB

반응형