Skip to content

Instantly share code, notes, and snippets.

@gravcat
Created March 2, 2018 21:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gravcat/22b8c655e8056123fdb1f10d59ee3160 to your computer and use it in GitHub Desktop.
Save gravcat/22b8c655e8056123fdb1f10d59ee3160 to your computer and use it in GitHub Desktop.
random wc3 lan install script. not done nor quality
#Requires -Version 4.0
#Requires -RunAsAdministrator
$ErrorActionPreference = "Stop"
$userHome = (Get-ChildItem Env:USERPROFILE).Value
cd $PSScriptRoot
$confirmation = Read-Host "This script will extract files to your Documents and Program Files (x86) folders, proceed? [y/n]"
while($confirmation -ne "y")
{
if ($confirmation -eq 'n') {exit}
$confirmation = Read-Host "Was that a typo? Let me know if you'd like to proceed. [y/n]"
}
$docExist = Test-Path "$userHome\Documents\Warcraft III"
$progFilesExist = Test-Path "C:\Program Files (x86)\Warcraft III"
checkExistingInstall
if ($docExist -eq $true -Or $progFilesExist -eq $true) {
$confirmation = Read-Host "We found that you have existing Warcraft III assets in either your documents folder, or the Program Files (x86) folder. We can overwrite this for you if desired? [y/n]"
while($confirmation -ne "y")
{
if ($confirmation -eq 'n') {exit}
$confirmation = Read-Host "Was that a typo? Let me know if you'd like to proceed. [y/n]"
}
if ($docExist) {
Move-Item -Force "C:\Program Files (x86)\Warcraft III" "existing\Documents\Warcraft III"
Write-Output "We saved your existing Warcraft III folder that was previously in $userHome\Documents"
}
if ($progFilesExist) {
Move-Item -Force "$userHome\Documents\Warcraft III" "existing\Program Files (x86)\Warcraft III"
Write-Output "We saved your existing Warcraft III folder that was previously in C:\Program Files (x86)\Warcraft III"
}
}
$docExist = Test-Path "$userHome\Documents\Warcraft III"
$progFilesExist = Test-Path "C:\Program Files (x86)\Warcraft III"
if ($docExist -eq $false -And $progFilesExist -eq $false) {
Copy-Item -Recurse "$PSScriptRoot\Warcraft III-documents\Warcraft III" "$userHome\Documents\"
Copy-Item -Recurse "$PSScriptRoot\Warcraft III-progfiles\Warcraft III" "C:\Program Files (x86)\"
Write-Output " +++ Move completed. Warcraft III installed to Program Files (x86), and user data folder in Documents +++ "
$confirmation = Read-Host "Create shortcut? [y/n]"
while($confirmation -ne "y")
{
if ($confirmation -eq 'n') {exit}
$confirmation = Read-Host "Was that a typo? Let me know if you'd like to proceed. [y/n]"
}
$Shell = New-Object -ComObject ("WScript.Shell")
$ShortCut = $Shell.CreateShortcut("$userHome\Desktop\Your Shortcut.lnk")
$ShortCut.TargetPath="C:\Program Files (x86)\Warcraft III\Frozen Throne.exe"
$ShortCut.WorkingDirectory = "C:\Program Files (x86)\Warcraft III\";
$ShortCut.IconLocation = "C:\Program Files (x86)\Warcraft III\Frozen Throne.exe, 0";
$ShortCut.Description = "WC3 from spacecrustacean";
$ShortCut.Save()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment