Advertisement
Guest User

Untitled

a guest
Feb 17th, 2020
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.42 KB | None | 0 0
  1. if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
  2. Start-Process PowerShell -Verb RunAs "-NoProfile -ExecutionPolicy Bypass -Command `"cd '$pwd'; & '$PSCommandPath';`"";
  3. exit;
  4. }
  5.  
  6.  
  7. function Test-ReparsePoint([string]$path) {
  8. $file = Get-Item $path -Force -ea SilentlyContinue
  9. return [bool]($file.Attributes -band [IO.FileAttributes]::ReparsePoint)
  10. }
  11.  
  12. if(Test-Path "A:\"){
  13. Write-Host "Ramdisk already mounted"
  14. } else {
  15. Write-Host "Ramdisk missing, creating now"
  16. cmd.exe /c "`"C:\Program Files\SoftPerfect RAM Disk\ramdiskws.exe`" /add:`"letter=A,fs=NTFS,size=1500M,type=boot,mount=yes`""
  17. }
  18.  
  19. $source="C:\Program Files (x86)\Atmel\studio\7.0"
  20. $dest="A:\Atmel"
  21.  
  22. if((Test-ReparsePoint("$source")) -AND (Test-Path "$source\toolchain")){
  23. Write-Host "Already manipulated atmel studio"
  24. } else {
  25. if(Test-Path "C:\Program Files (x86)\Atmel\studio\7.0_old"){
  26. Write-Host "Restoring old Atmel Studio"
  27. del -force "$source"
  28. cmd.exe /c "rename `"C:\Program Files (x86)\Atmel\studio\7.0_old`" `"7.0`""
  29. }
  30.  
  31. Write-Host "copy now"
  32.  
  33. $what = @("/MIR")
  34. #couldnt get options to work :(
  35. #$options = @("/XD:\toolchain\arm","/XD:\toolchain\avr32","/XD:\packs\atmel`"")
  36. $options = @("/NFL","/NDL")
  37.  
  38. $cmdArgs = @("$source","$dest",$what,$options)
  39. robocopy @cmdArgs /XD $source\toolchain\arm /XD $source\toolchain\avr32 /XD $source\packs\atmel
  40.  
  41. #copy missing pack
  42. $cmdArgs = @("$source\packs\atmel\ATmega_DFP","$dest\packs\atmel\ATmega_DFP",$what,$options)
  43. robocopy @cmdArgs
  44.  
  45. Write-Host "creating symlinks"
  46. cmd.exe /c "rename `"$source`" `"7.0_old "
  47. cmd.exe /c "mklink /J `"$source`" `"$dest`""
  48. }
  49.  
  50. $source="C:\Program Files (x86)\ATMega Remote"
  51. $dest="A:\ATMega Remote"
  52.  
  53. if((Test-ReparsePoint("$source")) -AND (Test-Path "$source\ATMega Remote.exe")){
  54. Write-Host "Already manipulated ATMR"
  55. } else {
  56. if(Test-Path "C:\Program Files (x86)\ATMega Remote_old"){
  57. Write-Host "Restoring old ATMR"
  58. del -force "$source"
  59. cmd.exe /c "rename `"C:\Program Files (x86)\ATMega Remote_old`" `"ATMega Remote`" "
  60. }
  61.  
  62. Write-Host "copy now"
  63.  
  64. $what = @("/MIR")
  65. $options = @("/NFL","/NDL")
  66.  
  67. $cmdArgs = @("$source","$dest",$what,$options)
  68. robocopy @cmdArgs
  69.  
  70. Write-Host "creating symlinks"
  71. cmd.exe /c "rename `"$source`" `"ATMega Remote_old "
  72. cmd.exe /c "mklink /J `"$source`" `"$dest`""
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement