Advertisement
metalx1000

Punisher ROM MAME

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