|
| 1 | +export module win { |
| 2 | + # do I have admin rights? |
| 3 | + export def "am i admin" [] { |
| 4 | + # https://stackoverflow.com/questions/7985755/how-to-detect-if-cmd-is-running-as-administrator-has-elevated-privileges |
| 5 | + if (net session | complete).exit_code == 0 { |
| 6 | + true |
| 7 | + } else { |
| 8 | + false |
| 9 | + } |
| 10 | + } |
| 11 | + |
| 12 | + # open in visual studio |
| 13 | + export def "open in vs-2022" [file: path] { |
| 14 | + let file = ($file | path expand) |
| 15 | + run-external `C:\Program Files\Microsoft Visual Studio\2022\Professional\Common7\IDE\devenv.exe` /Edit $file |
| 16 | + } |
| 17 | + |
| 18 | + export def "windbg attach-to-process" [ |
| 19 | + --pid(-p): int@"nu-complete processes" # process-id |
| 20 | + ] { |
| 21 | + |
| 22 | + ~/AppData/Local/Microsoft/WindowsApps/WinDbgX.exe -p $pid |
| 23 | + } |
| 24 | + |
| 25 | + # sigcheck wrapper, file version and signature viewer |
| 26 | + export def "which version" [file: path ] { |
| 27 | + print $"sigcheck -nobanner ($file)" |
| 28 | + ^sigcheck -nobanner $file | lines | skip 1 | parse --regex '\s*(?<name>.+?):(?<value>.+)' |
| 29 | + } |
| 30 | + |
| 31 | + # https://learn.microsoft.com/en-us/sysinternals/downloads/procdump#using-procdump |
| 32 | + # |
| 33 | + # Examples: |
| 34 | + # Install ProcDump as the (AeDebug) postmortem debugger: |
| 35 | + # procdump -ma -i c:\dumps |
| 36 | + # |
| 37 | + # Uninstall ProcDump as the (AeDebug) postmortem debugger: |
| 38 | + # procdump -u |
| 39 | + export extern "procdump" [ |
| 40 | + ...args: any # Arguments to be passed to your program |
| 41 | + # command?: string@"nu-complete rustup" |
| 42 | + ] |
| 43 | + |
| 44 | + def "nu-complete proc-names" [] { ps | get name | uniq } |
| 45 | + |
| 46 | + def "nu-complete ps-priority" [] { [ [value description]; [3 High] [6 'Above Normal'] [2 Normal] [5 'Below Normal'] [1 Low] ] } |
| 47 | + |
| 48 | + # permanently set priority for process in windows registry |
| 49 | + export def "ps set-permanent-priority" [ |
| 50 | + proc_name: string@"nu-complete proc-names" |
| 51 | + --cpu-priority: int@"nu-complete ps-priority" = 2 |
| 52 | + --io-priority: int@"nu-complete ps-priority" = 2 |
| 53 | + ] { |
| 54 | + # https://answers.microsoft.com/en-us/windows/forum/all/how-to-permanently-set-priority-processes-using/2f9ec439-5333-4625-9577-69d322cfbc5e |
| 55 | + let perf_options_path = $'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\($proc_name)\PerfOptions' |
| 56 | + reg add $perf_options_path /v CpuPriorityClass /t REG_DWORD /d $cpu_priority |
| 57 | + reg add $perf_options_path /v IoPriority /t REG_DWORD /d $io_priority |
| 58 | + } |
| 59 | + |
| 60 | +} |
| 61 | + |
0 commit comments