Advertisement
Guest User

Untitled

a guest
Nov 30th, 2018
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #Kill any previous process of DesktopInfo
  2. Get-Process | ? {$_.ProcessName -like "Desktopinfo"} | Stop-Process -ErrorAction SilentlyContinue
  3.  
  4. #Get resolution from Primary screen
  5. Add-Type -AssemblyName System.Windows.Forms
  6. $PrimWid = [System.Windows.Forms.SystemInformation]::PrimaryMonitorSize.Width
  7. $PrimHei = [System.Windows.Forms.SystemInformation]::PrimaryMonitorSize.Height
  8. $PrimRes = "$PrimWid"+'x'+"$PrimHei"
  9.  
  10. cd "C:\Program Files (x86)\DesktopInfo\DesktopInfo1102"
  11.  
  12. #Default Values
  13. $FileExe = ".\DesktopInfo.exe"
  14. $FileIni = ".\DesktopInfo.ini"
  15.  
  16. #Function to add value to .ini-file. Will be used to set the position of DesktopInfo
  17. function Set-OrAddIniValue
  18. {
  19.     Param(
  20.         [string]$FilePath,
  21.         [hashtable]$keyValueList
  22.     )
  23.  
  24.     $content = Get-Content $FilePath
  25.  
  26.     $keyValueList.GetEnumerator() | ForEach-Object {
  27.         if ($content -match "^$($_.Key)=")
  28.         {
  29.             $content= $content -replace "^$($_.Key)=(.*)", "$($_.Key)=$($_.Value)"
  30.         }
  31.         else
  32.         {
  33.             $content += "$($_.Key)=$($_.Value)"
  34.         }
  35.     }
  36.  
  37.     $content | Set-Content $FilePath
  38. }
  39.  
  40.  
  41. if($PrimRes -eq "1920x1080"){
  42.  
  43. $TopPos = "200"
  44. $LeftPos = ""
  45. $RightPos = "20"
  46. $FontSize = "14"
  47.  
  48. }elseif($PrimRes -eq "1366x768"){
  49.  
  50. $TopPos = "150"
  51. $LeftPos = "1040"
  52. $RightPos = "0"
  53. $FontSize = "11"
  54.  
  55. }elseif($PrimRes -eq "1920x1200"){
  56.  
  57. $TopPos = "230"
  58. $LeftPos = ""
  59. $RightPos = "20"
  60. $FontSize = "14"
  61.  
  62.  
  63. }
  64.  
  65.  
  66.  
  67. Set-OrAddIniValue -FilePath ".\desktopinfo.ini"  -keyValueList @{
  68.     Top = $TopPos
  69.     Left = $LeftPos
  70.     Right = $RightPos
  71.     'font-size' = $FontSize
  72.  
  73. }
  74.  
  75. #Execute program
  76. .\Desktopinfo.exe /ini=desktopinfo.ini
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement