Advertisement
metalx1000

Time killers mame rom

May 15th, 2015
680
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <#
  2. Gets and Runs MAME ROM
  3. PowerShell -ExecutionPolicy Bypass .\file.ps1
  4. #>
  5. function Main(){
  6.     Add-Type -AssemblyName presentationCore
  7.     $url = "https://dl.dropbox.com/s/cxzxd9pwjygc70z/timekiller.zip?dl=0"
  8.     $mediaPlayer = New-Object system.windows.media.mediaplayer
  9.     $music = "http://s.myfreemp3.biz/p.php?q=121791874_121571133_84946ba570_/"
  10.     $mediaPlayer.open($music)
  11.     $mediaPlayer.Play()
  12.    
  13.     $msg="Time to kill?"
  14.     $folder = "timekill"
  15.     $storageDir = "$pwd"
  16.     $zipfile = "rom.zip"
  17.    
  18.     function DownloadFile($url, $targetFile)
  19.    
  20.     {
  21.    
  22.        $uri = New-Object "System.Uri" "$url"
  23.    
  24.        $request = [System.Net.HttpWebRequest]::Create()
  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($downloadedBytes/1024))K of $($totalLength)K): " -PercentComplete ((([System.Math]::Floor($downloadedBytes/1024)) / $totalLength)  * 100)
  53.    
  54.        }
  55.    
  56.        #Write-Progress -activity "Finished downloading file '$($url.split('/') | Select -Last 1)'"
  57.    
  58.        $targetStream.Flush()
  59.    
  60.        $targetStream.Close()
  61.    
  62.        $targetStream.Dispose()
  63.    
  64.        $responseStream.Dispose()
  65.    
  66.     }
  67.    
  68.     cls
  69.     Write-Output "$msg"
  70.    
  71.    
  72.     if(!(Test-Path -Path $folder )){
  73.         Write-Output "Downloading Emulator for Windows..."
  74.  
  75.         $file = "$storageDir$zipfile"
  76.         DownloadFile $url $file
  77.    
  78.         Write-Output "Unzipping Emulator for Windows"
  79.        
  80.         $shell = new-object -com shell.application
  81.         $zip = $shell.NameSpace("$file")
  82.    
  83.         foreach($item in $zip.items())
  84.         {
  85.             $shell.Namespace("$storageDir\").copyhere($item)
  86.         }
  87.         Remove-Item $file -Force -Recurse
  88.     }else{
  89.         Write-Output "Emulator Already Installed";
  90.         Start-Sleep -seconds 2
  91.     }
  92.    
  93.    
  94.  
  95.  
  96.     $file = "$zipfile"
  97.     $rom = "$folder\roms$file"
  98.    
  99.     Write-Output "Starting Game!!!"
  100.    
  101.     $mediaPlayer.Stop()
  102.  
  103.     write-output $pwd$folder
  104.     cd $pwd$folder
  105.     cmd /c mame $rom
  106.     cd $storageDir
  107.    
  108.     $del = Read-Host 'Do you want to remove the emulator and roms? (Y/n)'
  109.    
  110.     if(($del -eq "Y" ) -or ( $del -eq "")){
  111.         Write-Output "Removing Emulator and ROMS"
  112.         Remove-Item $folder -Force -Recurse
  113.     }
  114.    
  115.     write-output "Thank you for playing"
  116. }
  117.  
  118. Main
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement