Advertisement
Guest User

Powershell Code

a guest
Jul 26th, 2014
480
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $Host.UI.RawUI.WindowTitle = "Oinkers Techpack Updater"
  2. $currentDirectory = [System.IO.Path]::GetDirectoryName($myInvocation.MyCommand.Definition)
  3. $parentDirectory = split-path (split-path $MyInvocation.MyCommand.Path -parent) -parent
  4. [System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms") |
  5. Out-Null
  6. $myDialog = New-Object System.Windows.Forms.OpenFileDialog
  7. $myDialog.Title = “Please select the Oinkers Modpack File:”
  8. $myDialog.InitialDirectory =$parentDirectory
  9. $myDialog.Filter = “Oinkers Modpack Files (*.oinkmod)| *.oinkmod”
  10. $result = $myDialog.ShowDialog()
  11. If($result -eq “OK”) {
  12. $inputFile = $myDialog.FileName
  13. copy-item $inputFile $currentDirectory\_temp.zip
  14. $shell=new-object -com shell.application
  15. $CurrentLocation=get-location
  16. $CurrentPath=$CurrentLocation.path
  17. $Location=$shell.namespace($CurrentPath)
  18. $ZipFiles = get-childitem *.zip
  19. $ZipFiles.count | out-default
  20. foreach ($ZipFile in $ZipFiles)
  21. {
  22. $ZipFile.fullname | out-default
  23. $ZipFolder = $shell.namespace($ZipFile.fullname)
  24. $Location.Copyhere($ZipFolder.items())
  25. }
  26. move-item $currentDirectory\add.bat $currentDirectory\TEMP -Force
  27. move-item $currentDirectory\remove.bat $currentDirectory\TEMP -Force
  28. move-item $currentDirectory\add $currentDirectory\TEMP -Force
  29. remove-item $currentDirectory\_temp.zip -Force
  30. Write-Host "Press any key to continue ..."
  31.  
  32. $x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
  33. }
  34. else {
  35. Write-Host “Cancelled by user, please try again!
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement