Skip to content

Instantly share code, notes, and snippets.

@aplocher
aplocher / sqlsrvhelper.bat
Last active August 29, 2015 14:02
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.
@echo off
rem ---------------------------------------------
rem - SQL SERVICE HELPER v1.1.20140624
rem - ADAM PLOCHER / BITCOLLECTORS
rem - https://github.com/aplocher
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
aplocher / DelUnusedConstants.ps1
Last active August 29, 2015 14:07
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…
$fileToCheck = 'C:\SourceCode\BitCollectors.WinFormsControls\BitCollectors.WinFormsControls\Common\Win32Native.cs'
$fileToOutput = 'C:\Temp\Win32Native.new.cs'
$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
aplocher / WebAdmin.bat
Last active August 29, 2015 14:12
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.
@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)
# 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
aplocher / CleanTemp.ps1
Created May 30, 2015 02:27
PowerShell command to clean temp folder (only if the file or folder hasn't been touched in the last 2 days)
Get-ChildItem $env:temp | Where-Object {$_.LastWriteTime -lt (Get-Date).AddDays(-2)} | Remove-Item -Force -Recurse
@aplocher
aplocher / FixWinUpdateOnWin10.bat
Created June 13, 2015 03:56
Fix Windows Update issues with Windows 10 (could likely fix issues experienced in Win 8.1 and earlier, too)
@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
aplocher / WindowsToolbarAutomation.ahk
Created August 31, 2015 13:13
AutoHotKey script to automate adding a toolbar to the taskbar in Windows
; Automates adding a toolbar to the taskbar in Windows
#SingleInstance force
; Change to the folder path to your toolbar
toolbarPath=OneDrive\System\Actions
ControlGet, handle, Hwnd,, TrayClockWClass1,,Notification Area
ControlClick, ,ahk_id %handle% ,,Right
WinWait,ahk_class #32768,,5
if ErrorLevel
@aplocher
aplocher / ArpHosts.ps1
Created January 11, 2016 02:18
Output based on (and similar to) arp -a, but includes hostnames. Will take a few seconds longer to run since it must reverse resolve each IP.
$hostColWidth = 40
arp -a | % {
$line=$_.ToString().Trim()
try {
if ($line -like "Interface:*" -or $line -eq "") {
$line
} elseif ($line -like "Internet Address*") {
" " + "HostName".PadRight($hostColWidth, ' ') + $line
} else {
$res=[System.Net.Dns]::gethostentry($line.ToString().Trim().Split(" ")[0])
@aplocher
aplocher / Backup.bat
Last active April 26, 2016 13:39
Sync two folders using VSS. Handy for syncing source code with a backup destination on OneDrive
@echo off & setlocal enabledelayedexpansion
:: Backup.bat:
:: Adam Plocher - gist.github.com/aplocher - bitcollectors.com
::
:: --Description:
:: Synchronize (backup) a directory to another dir using VSS (volume shadow copy
:: service) in Windows to help ensure a successful copy without locked files
:: impeding the process.
::
:: Can be called from command line or can be used to install a scheduled task
@aplocher
aplocher / FixSynaptics.bat
Created May 22, 2016 01:11
Since upgrading to Windows 10 the Synaptics driver will occasionally become unstable (specifically when explorer.exe dies) and cause the mouse cursor to lock up for a few seconds every couple of minutes. I've experienced this on my HP Elitebook 8470p and Elitebook 840G2, but it's likely occuring on any laptop with a Synaptics touch pad in Win10.…
@echo off
rem FOR RESETTING SYNAPTICS MOUSE DRIVER
rem HELPFUL FOR WHEN MOUSE REGULARLY FREEZES AFTER EXPLORER.EXE HANGS
rem OR SCROLL/GESTURES STOP WORKING RANDOMLY
taskkill -f -im syntpenh.exe
pushd C:\Program Files\Synaptics\SynTP
start "" "syntpenh.exe"
popd
timeout /t 2 /nobreak >nul
exit /b