Skip to content

Instantly share code, notes, and snippets.

View 0xfeeddeadbeef's full-sized avatar

Giorgi Chakhidze 0xfeeddeadbeef

View GitHub Profile
@0xfeeddeadbeef
0xfeeddeadbeef / BroadcastSettingsChange.ps1
Created May 15, 2023 09:07
Send WM_SETTINGCHANGE message from a PowerShell script
function _BroadcastSettingsChange
{
if ([Environment]::UserInteractive)
{
$win32native = @'
namespace EnvUtils
{
using System;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
@0xfeeddeadbeef
0xfeeddeadbeef / Test-ProcessElevated.ps1
Last active November 30, 2023 04:02
Test whether or not a process is elevated (UAC run as admin)
function Test-ProcessElevated
{
[CmdletBinding()]
[OutputType([bool])]
param (
[Parameter(Mandatory = $true, ValueFromPipeline = $true)]
[System.Diagnostics.Process] $Process
)
begin {
/*
* FipsSHA256SignatureDescription.cs
*
* Copyright (c) 2013-2018, Sustainsys and contributors. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
package com.gchakhidze.textsharpidea;
import com.intellij.injected.editor.DocumentWindow;
import com.intellij.openapi.editor.event.EditorFactoryEvent;
import com.intellij.util.ui.GraphicsUtil;
import org.jetbrains.annotations.NotNull;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
# This internal function will download latest NetSqlAzMan.dll from NuGet (if necessary) and import it into runspace:
function _DownloadAndImportLatestNetSqlAzManDll
{
$DownloadUrl = 'https://api.nuget.org/packages/netsqlazman-x64.3.6.0.15.nupkg'
$LocalDir = Join-Path $env:TEMP 'NetSqlAzMan'
$LocalNupkg = Join-Path $LocalDir 'netsqlazman-x64.3.6.0.15.nupkg'
$DllPath = Join-Path $LocalDir 'lib\net40\NetSqlAzMan.dll'
if (-not (Test-Path $LocalDir)) {