Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Kill any previous process of DesktopInfo
- Get-Process | ? {$_.ProcessName -like "Desktopinfo"} | Stop-Process -ErrorAction SilentlyContinue
- #Get resolution from Primary screen
- Add-Type -AssemblyName System.Windows.Forms
- $PrimWid = [System.Windows.Forms.SystemInformation]::PrimaryMonitorSize.Width
- $PrimHei = [System.Windows.Forms.SystemInformation]::PrimaryMonitorSize.Height
- $PrimRes = "$PrimWid"+'x'+"$PrimHei"
- cd "C:\Program Files (x86)\DesktopInfo\DesktopInfo1102"
- #Default Values
- $FileExe = ".\DesktopInfo.exe"
- $FileIni = ".\DesktopInfo.ini"
- #Function to add value to .ini-file. Will be used to set the position of DesktopInfo
- function Set-OrAddIniValue
- {
- Param(
- [string]$FilePath,
- [hashtable]$keyValueList
- )
- $content = Get-Content $FilePath
- $keyValueList.GetEnumerator() | ForEach-Object {
- if ($content -match "^$($_.Key)=")
- {
- $content= $content -replace "^$($_.Key)=(.*)", "$($_.Key)=$($_.Value)"
- }
- else
- {
- $content += "$($_.Key)=$($_.Value)"
- }
- }
- $content | Set-Content $FilePath
- }
- if($PrimRes -eq "1920x1080"){
- $TopPos = "200"
- $LeftPos = ""
- $RightPos = "20"
- $FontSize = "14"
- }elseif($PrimRes -eq "1366x768"){
- $TopPos = "150"
- $LeftPos = "1040"
- $RightPos = "0"
- $FontSize = "11"
- }elseif($PrimRes -eq "1920x1200"){
- $TopPos = "230"
- $LeftPos = ""
- $RightPos = "20"
- $FontSize = "14"
- }
- Set-OrAddIniValue -FilePath ".\desktopinfo.ini" -keyValueList @{
- Top = $TopPos
- Left = $LeftPos
- Right = $RightPos
- 'font-size' = $FontSize
- }
- #Execute program
- .\Desktopinfo.exe /ini=desktopinfo.ini
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement