Skip to content

Instantly share code, notes, and snippets.

@neremin
neremin / INSTALL_TCMD (overrides_inireloc).ps1
Created May 3, 2018 22:16
Total Commander portable registration (run from TCMD folder)
## Autorun script as Administrator
$admin = [Security.Principal.WindowsBuiltInRole] "Administrator"
$identity = [Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()
if (!$identity.IsInRole($admin)) {
Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs; exit
}
## Admin tasks
$tcmdDir = (Get-Item -Path $PSCommandPath).Directory.FullName
@neremin
neremin / Clean_SoftwareDistribution.ps1
Last active May 26, 2021 01:20
Windows 10 fine-tuning
## Autorun script as Administrator
$admin = [Security.Principal.WindowsBuiltInRole] "Administrator"
$identity = [Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()
if (!$identity.IsInRole($admin)) {
Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs; exit
}
## Admin tasks
@neremin
neremin / Install.ps1
Created April 29, 2018 13:30
Offline NuGet Repository installation.
function NuGetAddLocalRepo ([string] $localRepoPath)
{
## NuGet Package Manager config file path
$config = "$Env:APPDATA\NuGet\NuGet.Config"
If ( -Not (Test-Path($config)) ) {
Write-Host "NuGet Package Manager config not found!"
return
}
@neremin
neremin / ProgressBar.cs
Last active April 27, 2018 13:11 — forked from DanielSWolf/Program.cs
Console progress bar. Code is under the MIT License: http://opensource.org/licenses/MIT
using System;
using System.Text;
using System.Threading;
/// <summary>
/// An ASCII progress bar
/// </summary>
public class ProgressBar : IDisposable, IProgress<double>
{
private const int blockCount = 10;
@neremin
neremin / StuckPixelFix.cs
Created April 25, 2018 07:29
Full screen stuck pixel fixer, inspired by http://www.jscreenfix.com.
using System;
using System.Collections.Concurrent;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Imaging;
using System.Linq;
using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
@neremin
neremin / Module1.bas
Created June 12, 2017 20:41 — forked from kumatti1/Module1.bas
VBA_Test
Option Explicit
Declare PtrSafe Function DispInvoke Lib "OleAut32" _
(ByVal arg1 As LongPtr, _
ByVal arg2 As LongPtr, _
ByVal arg3 As Long, _
ByVal arg4 As Integer, _
arg5 As Any, _
arg6 As Variant, _
arg7 As Any, _
@neremin
neremin / winsxs_ntfs_compress.bat
Last active December 2, 2023 06:30
WinSxS folder compression script
@ECHO off
net session >nul 2>&1
IF %ERRORLEVEL% NEQ 0 GOTO ELEVATE
@GOTO ADMINTASKS
:ELEVATE
ECHO Elevated privileges are temporarily required to run script
cd /d %~dp0
mshta "javascript: var shell = new ActiveXObject('Shell.Application'); shell.ShellExecute('%~nx0', '', '', 'runas', 1); close();"
@neremin
neremin / st3_register.bat
Last active April 6, 2018 15:34
Batch script for Sublime Text 3 shell menus & launch alias ("st.exe") registering. Keep it next to sublime_text.exe and run.
@ECHO off
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
@IF %ERRORLEVEL% NEQ 0 GOTO ELEVATE
@GOTO ADMINTASKS
:ELEVATE
ECHO Elevated privileges are temporarily required to run script
cd /d %~dp0
mshta "javascript: var shell = new ActiveXObject('Shell.Application'); shell.ShellExecute('%~nx0', '', '', 'runas', 1); close();"
@neremin
neremin / BAT_CMD_runAsAdmin_fix.bat
Last active January 28, 2021 16:32
Template for windows cmd shell scripts (BAT, CMD) which need to auto-request user run as Administrator. Plus script for fixing "Run as Administrator" on batch files.
@ECHO off
net session >nul 2>&1
IF %ERRORLEVEL% NEQ 0 GOTO ELEVATE
@GOTO ADMINTASKS
:ELEVATE
ECHO Elevated privileges are temporarily required to run script
cd /d %~dp0
mshta "javascript: var shell = new ActiveXObject('Shell.Application'); shell.ShellExecute('%~nx0', '', '', 'runas', 1); close();"
@neremin
neremin / InvokeScript.tasks
Created May 12, 2015 16:23
Provide means for invoking inline PS scripts from MSBuild
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- USAGE EXAMPLE
<PropertyGroup>
<MyScript><![CDATA[
function Foo()
{
$targetFileName = args[0]
$targetPdbName = args[1]
$targetPath = args[2]