Skip to content

Instantly share code, notes, and snippets.

aplocher / sqlsrvhelper.bat
Last active Aug 29, 2015
Helper bat file to start / stop SQL server instances. Will require user intervention (pause) when error occurs. Supports colorized output if cmdcolor.exe is available in the same dir or in the environment PATH.
View sqlsrvhelper.bat
@echo off
rem ---------------------------------------------
rem - SQL SERVICE HELPER v1.1.20140624
rem -
rem -
rem - Description:
rem - Helper bat file to start / stop SQL server instances. Will require
rem - user intervention (pause) when error occurs. Supports colorized output
aplocher / DelUnusedConstants.ps1
Last active Aug 29, 2015
This is a basic script that helps cleanup a series of unused constants in a single file by scanning all *.cs files from a folder to try to find any usages. If not found, it will get commented out and the dev will be able to easily Find/Replace all commented lines with an empty line after verifying that nothing is broken. It uses text parsing, so…
View DelUnusedConstants.ps1
$fileToCheck = 'C:\SourceCode\BitCollectors.WinFormsControls\BitCollectors.WinFormsControls\Common\Win32Native.cs'
$fileToOutput = 'C:\Temp\'
$fileToBackup = 'C:\Temp\Win32Native.old.cs'
$folderToLookIn = 'C:\SourceCode\BitCollectors.WinFormsControls\BitCollectors.WinFormsControls'
$constRegex = '^\s*[^\/]\s*((internal|private|public|protected)?\s+const\s+[a-zA-Z0-9]+)?\s+([A-Z]{1}[a-zA-Z0-9_]+)\s*\=.*(;|,)\s*$'
$csFiles = Get-ChildItem -Path $folderToLookIn -Recurse -Filter '*.cs'
#region Functions
Function OnLoad {
aplocher / WebAdmin.bat
Last active Aug 29, 2015
Starts the ASP.NET Website Admin Tool (WSAT) and launches a web browser to it. WSAT is no longer a prominent feature in VS2013 - this BAT file will assist with easily launching it with a single command.
View WebAdmin.bat
@echo off
:: Begin config section
set pathToApp=C:\SourceCode\MyApp\MyApp.Web
set pathToIISExpress=C:\Program Files\IIS Express\iisexpress.exe
set webPort=8019
:: End config section
if not exist %pathToApp% (goto errMissingApp)
if not exist %pathToIISExpress% (goto errMissingIisExpress)
View FixWin10ShellExp.ps1
# Tested with Windows 10 Tech Preview build 9926
# The following PowerShell script can be used to re-initialize the Shell Experience in Windows 10.
# WARNING: All store apps will be reinitialized meaning any local data associated with that app will
# get reset.
# This seems to be necessary if restoring from a restore point. When a restore point is used,
# the Start Menu, Cortana, and the Notification Area no longer work
aplocher / ClearVisualStudioExpHive.ps1
Created Feb 25, 2015
Powershell script to list or remove Visual Studio hives
View ClearVisualStudioExpHive.ps1
param (
[string]$fullName = "", # Example: "12.0Exp" is VS v12.0 (2013) hive name "Exp"
[switch]$listHives = $false,
[switch]$force = $false
$vsAppDataRoot = Join-Path $env:APPDATA "Microsoft\VisualStudio"
$vsRegKeyRoot = "hkcu:\Software\Microsoft\VisualStudio"
if (-not $fullName -and -not $listHives) {
aplocher / CleanTemp.ps1
Created May 30, 2015
PowerShell command to clean temp folder (only if the file or folder hasn't been touched in the last 2 days)
View CleanTemp.ps1
Get-ChildItem $env:temp | Where-Object {$_.LastWriteTime -lt (Get-Date).AddDays(-2)} | Remove-Item -Force -Recurse
aplocher / FixWinUpdateOnWin10.bat
Created Jun 13, 2015
Fix Windows Update issues with Windows 10 (could likely fix issues experienced in Win 8.1 and earlier, too)
View FixWinUpdateOnWin10.bat
@echo off
:: Windows 10 Update issues
:: Stop / Disable Windows Update
sc config wuauserv start=disabled
taskkill /f /fi "SERVICES eq wuauserv"
net stop wuauserv
:: Clean temp files [where modified date not within the last 24 hours]
powershell.exe -ExecutionPolicy Bypass -Command "Get-ChildItem $env:temp | Where-Object {$_.LastWriteTime -lt (Get-Date).AddDays(-1)} | Remove-Item -Force -Recurse"
aplocher / BackupDismFeatures.ps1
Created Aug 22, 2015
Small PowerShell script that looks at the currently installed Windows Features on the current system and generates a dism.exe/ cmd.exe command to be used to restore those features. Handy for when you're reinstalling Windows on a machine and want to backup / restore your IIS, Hyper-V, etc configuration.
View BackupDismFeatures.ps1
Get-WindowsOptionalFeature -Online | where State -eq Enabled | %{$o += ("/FeatureName:"+$_.FeatureName+" ")}
Write-Host "dism.exe /Online /Enable-Feature $o/All"
aplocher / AnyConnect.ahk
Last active Feb 25, 2021
AutoHotKey script for Cisco AnyConnect. Takes hostname, username, and password as external args. Great for creating multiple shortcuts if you have more than one AnyConnect VPN.
View AnyConnect.ahk
; Create a shortcut to this file in Windows for each AnyConnect VPN configuration you need
; Each shortcut can have a different host, user, and pass defined (3 command line args)
; Usage: AutoHotKey.exe AnyConnect.ahk hostname username password
#SingleInstance force
if 0 < 3 ; The left side of a non-expression if-statement is always the name of a variable.
MsgBox This script requires at least 3 incoming parameters but it only received %0%.
aplocher / WindowsToolbarAutomation.ahk
Created Aug 31, 2015
AutoHotKey script to automate adding a toolbar to the taskbar in Windows
View WindowsToolbarAutomation.ahk
; Automates adding a toolbar to the taskbar in Windows
#SingleInstance force
; Change to the folder path to your toolbar
ControlGet, handle, Hwnd,, TrayClockWClass1,,Notification Area
ControlClick, ,ahk_id %handle% ,,Right
WinWait,ahk_class #32768,,5
if ErrorLevel