Advertisement
metalx1000

Metal Slug 5 MAME ROM

May 12th, 2015
458
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <#
  2. Gets and Runs Metal Slug 5 MAME ROM
  3. PowerShell -ExecutionPolicy Bypass .\mslug5.ps1
  4. #>
  5. function Main(){
  6.     Add-Type -AssemblyName presentationCore
  7.     $url = "https://dl.dropbox.com/s/5jcka430xcbgo1i/mslug5.zip"
  8.     $mediaPlayer = New-Object system.windows.media.mediaplayer
  9.     $music = "http://216.227.134.162/ost/metal-slug/rxgakwrpvq/03-stage-2.mp3"
  10.     $mediaPlayer.open($music)
  11.     $mediaPlayer.Play()
  12.    
  13.     $msg="Get Ready to Sling Some Lead!!!"
  14.     $folder = "mslug5"
  15.     $storageDir = "$pwd"
  16.     $zipfile = "mslug5.zip"
  17.    
  18.     function DownloadFile($url, $targetFile)
  19.    
  20.     {
  21.    
  22.        $uri = New-Object "System.Uri" "$url"
  23.    
  24.        $request = [System.Net.HttpWebRequest]::Create($uri)
  25.    
  26.        $request.set_Timeout(15000) #15 second timeout
  27.    
  28.        $response = $request.GetResponse()
  29.    
  30.        $totalLength = [System.Math]::Floor($response.get_ContentLength()/1024)
  31.    
  32.        $responseStream = $response.GetResponseStream()
  33.    
  34.        $targetStream = New-Object -TypeName System.IO.FileStream -ArgumentList $targetFile, Create
  35.    
  36.        $buffer = new-object byte[] 10KB
  37.    
  38.        $count = $responseStream.Read($buffer,0,$buffer.length)
  39.    
  40.        $downloadedBytes = $count
  41.    
  42.        while ($count -gt 0)
  43.    
  44.        {
  45.    
  46.            $targetStream.Write($buffer, 0, $count)
  47.    
  48.            $count = $responseStream.Read($buffer,0,$buffer.length)
  49.    
  50.            $downloadedBytes = $downloadedBytes + $count
  51.    
  52.            Write-Progress -activity "Downloading file '$($url.split('/') | Select -Last 1)'" -status "Downloaded ($([System.Math]::Floor
  53.  
  54. ($downloadedBytes/1024))K of $($totalLength)K): " -PercentComplete ((([System.Math]::Floor($downloadedBytes/1024)) / $totalLength)  * 100)
  55.    
  56.        }
  57.    
  58.        #Write-Progress -activity "Finished downloading file '$($url.split('/') | Select -Last 1)'"
  59.    
  60.        $targetStream.Flush()
  61.    
  62.        $targetStream.Close()
  63.    
  64.        $targetStream.Dispose()
  65.    
  66.        $responseStream.Dispose()
  67.    
  68.     }
  69.    
  70.     cls
  71.     Write-Output "$msg"
  72.    
  73.    
  74.     if(!(Test-Path -Path $folder )){
  75.         Write-Output "Downloading Emulator for Windows..."
  76.  
  77.         $file = "$storageDir\$zipfile"
  78.         DownloadFile $url $file
  79.    
  80.         Write-Output "Unzipping Emulator for Windows"
  81.        
  82.         $shell = new-object -com shell.application
  83.         $zip = $shell.NameSpace("$file")
  84.    
  85.         foreach($item in $zip.items())
  86.         {
  87.             $shell.Namespace("$storageDir\").copyhere($item)
  88.         }
  89.         Remove-Item $file -Force -Recurse
  90.     }else{
  91.         Write-Output "Emulator Already Installed";
  92.         Start-Sleep -seconds 2
  93.     }
  94.    
  95.    
  96.  
  97.  
  98.     $file = "$zipfile"
  99.     $rom = "$folder\roms\$file"
  100.    
  101.     Write-Output "Starting Game!!!"
  102.    
  103.     $mediaPlayer.Stop()
  104.  
  105.     write-output $pwd\$folder
  106.     cd $pwd\$folder
  107.     cmd /c mame $rom
  108.     cd $storageDir
  109.    
  110.     $del = Read-Host 'Do you want to remove the emulator and roms? (Y/n)'
  111.    
  112.     if(($del -eq "Y" ) -or ( $del -eq "")){
  113.         Write-Output "Removing Emulator and ROMS"
  114.         Remove-Item $folder -Force -Recurse
  115.     }
  116.    
  117.     write-output "Thank you for playing"
  118. }
  119.  
  120. Main
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement