Self Escalating Batch

use this version of Sudo for Windows… it goes to some length to keep the activity inside the current dos console.

 1 2 3 4 5 6 7 8 910
@echo off
setlocal

::self escalate
net session >nul 2>&1
::we need the timeout here versus in the main body logic...
::because sudo remaps stdin which then fails  timeout's "press any key to continue" 
if %errorlevel% NEQ 0 (sudo %0 & timeout /t 5 & exit /b)

::...rest of your logic...

ListShortcuts.csx

#r “Interop.IWshRuntimeLibrary.dll” //generated by referencing "Windows Script Host Object Model" in Visual Studio project //from here: http://stackoverflow.com/a/4909475/813599 using IWshRuntimeLibrary; using System.Text.RegularExpressions; var wsh = new WshShell(); var shortcutFileNames = System.IO.Directory.EnumerateFiles(Env.ScriptArgs[0], "*.lnk"); var wshShortcuts = new Dictionary<String, IWshShortcut>(); foreach (var shortcutFileName in shortcutFileNames) wshShortcuts[Regex.Match(shortcutFileName, ".*?- (.*?).lnk").Groups[1].Value] = (IWshShortcut)wsh.CreateShortcut(shortcutFileName); //var maxFileNameLength = wshShortcuts.Max(kv=>kv.Key.Length); Console.WriteLine("Display Name | Target | Arguments"); Console.WriteLine("--- | --- | ---"); foreach(var sc in wshShortcuts) Console.WriteLine($"{sc.Key} | {sc.Value.TargetPath} | {sc.

Launch .CSX as conveniently as .BAT files

first, get Chocolatety if you don’t already have… killer handy @powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin" then make sure you have a .csx runner… either ScriptCS or csi.exe starting with Visual Studio 2015 update 3 choco install ScriptCS setup the .csx to runner file association assoc .csx=CSharpScript ftype csharpscript=C:\ProgramData\chocolatey\bin\scriptcs.exe %1 -- %~2 %~2 means all args starting with #2… see ftype docs for more

Using “C# Interactive” aka CSI/CSX for ETL

motivation interactive C# offers typical REPL benefits ala powershell without the mental context switch required to leave our beloved C# syntax =)   notable great MSDN reference article CSX syntax can be executed from either Visual Studio 2015 (as of update 1) > View > Other Windows > C# Interactive -or- C:\Program Files (x86)\MSBuild\14.0\bin\csi.exe then #load file.csx Extract this example is based on a low fidelity web page as the raw data source

Bash script – loop over inline list of files

#!/bin/bash #echo $BASH_VERSION # read args: # -r = disable backslash escaping # -d '' = read the whole here-doc as one big input vs stopping stopping at the first new line as the default delimiter # -a = put the results into an array #the minus in "

[SOLVED] Acer Aspire One won’t boot Syslinux USB thumbdrive

Looks like my particular issue was the default partition size on my 16GB thumbdrive. Once I formatted the USB with a 2GB partition and installed Syslinux to that, it booted up right away where previously it would hang on the first “Syslinux Copyright Peter Anvin” message. More details: Acer Aspire One model#: 722-C62bb (looks like this is an 11” model) Always handy to have another computer to work from (for web searching, trial and error formats on the USB drive, etc) when trying to fiddle with boot issues on another… my other computer is a Win8 desktop.

SED – Insert text after match

General syntax: sed “s/search-for-regex/& replace-with/” filename.txt Example: sed “s/BEGIN AS/& nnSET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED/” Plans_s.sql Explanation: s/search-for-regex/replace-with/ = search and replace command & = the matched text (effectively leaves the matched text alone rather than “replacing” it) n = carriage return

SQL Split AWK Script

Split the output from SQL Server Management Studio (SSMS) > View > Object Explorer Details > “Script {function|view|procedure} as” into individual files Note: The current RegEx’s are tailored around the following scripting options (see comments to change): “Include descriptive headers” = true  (this is the default after SSMS 2008 install) – located under:  SSMS > Tools > Options > SQL Server Object Explorer > Scripting > General scripting options) “Schema qualify object names” =  false (NOT the default) – under: … > Object scripting options Download GAWK.

SymLinks (and their ilk) Are Excellent System Restore ‘Glue’

Ok i know this is 20+ years late for anybody that’s enjoyed any of the sweet but non mainstreamy flavors of  ‘nix… but now that Vista (blech!!) and Windows 7’s version of NTFS supports SymLinks (aka Soft) & HardLinks so well we can enjoy ourselves just as much over in Mr. Bill’s backyard (or I guess it’s Mr. Ozzie’s backyard now aint it) Go get this puppy: Link Shell Extension Nevermind that his version history starts at 1999 😐 We can rest easy that Vista was the first to do an actual Symbolic Link (i.