Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <#
- Gets and Runs MAME ROM
- PowerShell -ExecutionPolicy Bypass .\file.ps1
- #>
- function Main(){
- Add-Type -AssemblyName presentationCore
- $url = "https://dl.dropbox.com/s/cxzxd9pwjygc70z/timekiller.zip?dl=0"
- $mediaPlayer = New-Object system.windows.media.mediaplayer
- $music = "http://s.myfreemp3.biz/p.php?q=121791874_121571133_84946ba570_/"
- $mediaPlayer.open($music)
- $mediaPlayer.Play()
- $msg="Time to kill?"
- $folder = "timekill"
- $storageDir = "$pwd"
- $zipfile = "rom.zip"
- function DownloadFile($url, $targetFile)
- {
- $uri = New-Object "System.Uri" "$url"
- $request = [System.Net.HttpWebRequest]::Create()
- $request.set_Timeout(15000) #15 second timeout
- $response = $request.GetResponse()
- $totalLength = [System.Math]::Floor($response.get_ContentLength()/1024)
- $responseStream = $response.GetResponseStream()
- $targetStream = New-Object -TypeName System.IO.FileStream -ArgumentList $targetFile, Create
- $buffer = new-object byte[] 10KB
- $count = $responseStream.Read($buffer,0,$buffer.length)
- $downloadedBytes = $count
- while ($count -gt 0)
- {
- $targetStream.Write($buffer, 0, $count)
- $count = $responseStream.Read($buffer,0,$buffer.length)
- $downloadedBytes = $downloadedBytes + $count
- 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)
- }
- #Write-Progress -activity "Finished downloading file '$($url.split('/') | Select -Last 1)'"
- $targetStream.Flush()
- $targetStream.Close()
- $targetStream.Dispose()
- $responseStream.Dispose()
- }
- cls
- Write-Output "$msg"
- if(!(Test-Path -Path $folder )){
- Write-Output "Downloading Emulator for Windows..."
- $file = "$storageDir$zipfile"
- DownloadFile $url $file
- Write-Output "Unzipping Emulator for Windows"
- $shell = new-object -com shell.application
- $zip = $shell.NameSpace("$file")
- foreach($item in $zip.items())
- {
- $shell.Namespace("$storageDir\").copyhere($item)
- }
- Remove-Item $file -Force -Recurse
- }else{
- Write-Output "Emulator Already Installed";
- Start-Sleep -seconds 2
- }
- $file = "$zipfile"
- $rom = "$folder\roms$file"
- Write-Output "Starting Game!!!"
- $mediaPlayer.Stop()
- write-output $pwd$folder
- cd $pwd$folder
- cmd /c mame $rom
- cd $storageDir
- $del = Read-Host 'Do you want to remove the emulator and roms? (Y/n)'
- if(($del -eq "Y" ) -or ( $del -eq "")){
- Write-Output "Removing Emulator and ROMS"
- Remove-Item $folder -Force -Recurse
- }
- write-output "Thank you for playing"
- }
- Main
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement