Last active
December 27, 2015 00:09
-
-
Save sheeeng/7235195 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
######################################################################## | |
# File : GetDependencyWalker.ps1 | |
# Version : 1.0.0 | |
# Purpose : Downloads the Dependency Walker tool. | |
# Synopsis: http://www.dependencywalker.com/ | |
# Usage : .\GetDependencyWalker.ps1 ("x86","x64","ia64","32","64") | |
# Author: Leonard Lee <sheeeng@gmail.com> | |
######################################################################## | |
# References: | |
# Manage BITS (Background Intelligent Transfer Service) with Windows PowerShell | |
# http://technet.microsoft.com/en-us/magazine/ff382721.aspx | |
# Using Windows PowerShell to Create BITS Transfer Jobs | |
# http://msdn.microsoft.com/en-us/library/windows/desktop/ee663885(v=vs.85).aspx | |
# Copying Folders by Using the Shell Folder Object | |
# http://technet.microsoft.com/en-us/library/ee176633.aspx | |
######################################################################## | |
Param( | |
[ValidateSet("x86","x64","ia64","32","64")] | |
[parameter(Mandatory=$true, Position=1)] | |
[alias("Versi")] | |
$Version) | |
if($Version) { | |
Write-Host "You have selected $Version version." | |
} | |
else { | |
Write-Host "Version is empty!" | |
Break | |
} | |
Import-Module BitsTransfer | |
$DebugPreference = "SilentlyContinue" #Continue | |
Write-Debug $DebugPreference | |
Set-Location $HOME | |
$currentDirectory = $HOME | |
if ($Version -eq "x86" -or $Version -eq "32") | |
{ | |
$zipFile = "depends22_x86.zip" | |
$targetDirectory = $HOME.ToString() + "\" + "depends22_x86" | |
$downloadLink = "http://www.dependencywalker.com/depends22_x86.zip" | |
} elseif ($Version -eq "x64" -or $Version -eq "64") { | |
$zipFile = "depends22_x64.zip" | |
$targetDirectory = $HOME.ToString() + "\" + "depends22_x64" | |
$downloadLink = "http://www.dependencywalker.com/depends22_x64.zip" | |
} elseif ($Version -eq "ia64") { | |
$zipFile = "depends22_ia64.zip" | |
$targetDirectory = $HOME.ToString() + "\" + "depends22_ia64" | |
$downloadLink = "http://www.dependencywalker.com/depends22_ia64.zip" | |
} else { | |
Break | |
} | |
$sourceZipFile = $currentDirectory + "\" + $zipFile | |
if (Test-Path -path $targetDirectory) { | |
Write-Host "The" $targetDirectory "directory exist." | |
} | |
else { | |
Write-Host "Creating" $targetDirectory "directory since it does not exist." | |
New-Item -ItemType directory -Path $targetDirectory | |
} | |
Start-BitsTransfer -Source $downloadLink | |
function Expand-ZIPFile($file, $destination) | |
{ | |
#Write-Host "`$file:" $file | |
#Write-Host "`$destination:" $destination | |
$shell = New-Object -ComObject Shell.Application | |
$zip = $shell.NameSpace($file) | |
foreach($item in $zip.items()) | |
{ | |
$shell.Namespace($destination).CopyHere($item, 0x14) | |
} | |
} | |
$processName = "depends" | |
if (Get-Process $processName -ErrorAction SilentlyContinue) { | |
#Write-Host "The" $processName "process exist. Trying to stop..." | |
Stop-Process -processname $processName | |
} | |
else { | |
#Write-Host "The" $processName "process does not exist." | |
} | |
Expand-ZIPFile –File $sourceZipFile $targetDirectory | |
Write-Host "Update completed." | |
#Invoke-Item $targetDirectory |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment