-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathset-cursor.ps1
More file actions
52 lines (40 loc) · 1.49 KB
/
set-cursor.ps1
File metadata and controls
52 lines (40 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# Cursor paths
$DefaultCursor = "C:\Windows\Cursors\aero_arrow.cur"
$CustomCursor = "C:\Users\NAME\path\to\custom_cursor.cur"
# Registry path
$RegPath = "HKCU:\Control Panel\Cursors"
# Desktop log file
$Desktop = [Environment]::GetFolderPath("Desktop")
$LogFile = Join-Path $Desktop "RDP-CURSOR-STATUS.log"
# Check if rdpclip.exe is running → RDP session
$IsRdp = Get-Process rdpclip -ErrorAction SilentlyContinue
$Mode = if ($IsRdp) { "rdp" } else { "local" }
# Decide which cursor to use
$CursorToUse = if ($Mode -eq "rdp") { $DefaultCursor } else { $CustomCursor }
<#
# Write mode to log - uncomment to use
@"
[$(Get-Date)] Mode: $Mode | rdpclip running: $([bool]$IsRdp) | Cursor set to: $CursorToUse
"@ | Out-File -FilePath $LogFile -Append -Encoding utf8
Write-Host "Mode: $Mode"
Write-Host "Cursor set to: $CursorToUse"
Write-Host "rdpclip running: $([bool]$IsRdp)"
Write-Host "Updating registry..."
#>
# Update the cursor in registry
Set-ItemProperty -Path $RegPath -Name Arrow -Value $CursorToUse
# Force Windows to reload cursors immediately
Add-Type @"
using System;
using System.Runtime.InteropServices;
public class CursorRefresh {
[DllImport("user32.dll", SetLastError=true)]
public static extern bool SystemParametersInfo(
int uiAction, int uiParam, IntPtr pvParam, int fWinIni);
}
"@
# SPI_SETCURSORS = 0x57
[CursorRefresh]::SystemParametersInfo(0x57, 0, [IntPtr]::Zero, 0)
Write-Host "Cursor updated!"
Write-Host "Waiting 30 seconds to read output..."
Start-Sleep -Seconds 30