Skip to content

Instantly share code, notes, and snippets.

@davidruhmann
davidruhmann / DownloadGists.bat
Last active March 27, 2024 14:25
[Batch] [PowerShell] Download Gists
@echo off
:Main <Username> [Destination=CD]
call :DownloadGists %1 %2 "%CD%"
exit /b
:: TODO Support duplicate file names.
:: Current pagination limit set to 1000
:DownloadGists <Username> <Destination> ~UI/IO
PowerShell -NoProfile -ExecutionPolicy RemoteSigned -Command "$c = New-Object System.Net.WebClient; $c.Headers.Add('user-agent', 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2;)'); $c.DownloadString('https://api.github.com/users/%~1/gists?per_page=1000').Split(',') | ForEach { $_.Split('{') | ForEach { $_.Split('}') | ForEach { If ($_.Contains('filename')) { Write-Host ($f = $_.Split([char]0x0022)[3].Replace(([char]0x0022).ToString(), '')) } ElseIf ($_.Contains('raw_url')) { $c.DownloadFile($_.Split([char]0x0022)[3].Replace(([char]0x0022).ToString(), ''), '%~2\' + $f) } } } };"
exit /b
@davidruhmann
davidruhmann / Clock.bat
Last active March 27, 2024 14:00
[Batch] Timer script with real clock sync
@echo off
setlocal
:initialize
set "s=10"
set "m=10"
:: Note Offset
set "xs=%time:~6,1%" & set "sx=%time:~7,1%"
set "xm=%time:~3,1%" & set "mx=%time:~4,1%"
set "so=%xs:0=%%sx%" & set "mo=%xm:0=%%mx%"
echo Offset: %mo% : %so%
  1. Insert the unifying receiver.
  2. Download and Install the latest Unifying Receiver software. (version 250, firmware 024.010.00036 at time of writing)
  3. Download and Install the latest SetPoint software. (version 6.69.126, firmware 041.001.00038 at time of writing)
  4. Sync the T650 to your unifying receiver.
  5. Open SetPoint and make any changes to the SetPoint configuration for your T650.
    • You may need to restart the T650 and SetPoint for initial detection.
  6. Exit/close the SetPoint software (make sure it is fully closed and not in the tasktray)
  7. Open the Properties for C:\Program Files\Logitech\SetPointP\SetPoint.exe
@davidruhmann
davidruhmann / RemoveIE.bat
Last active July 11, 2023 05:27
[Batch] Uninstall Internet Explorer 9, 10, or 11
@echo off
:: Usage script.bat [version [verify [reboot]]]
:: Version Prompt
setlocal
:Version
set "Input=%~1"
set /p "Input=> Which Version of Internet Explorer? (8, 9, 10, or 11): "
if defined Input set "Input=%Input:"=%"
if /i "%Input%"=="8" goto SetVersion
@davidruhmann
davidruhmann / Example_DelayedExpansion.bat
Created December 4, 2012 21:27
[Batch] Detect SetLocal DelayedExpansion or EnableExtensions support.
:: Detect if Delayed Expansion or Command Extensions is supported.
:: Identify if delayed expansion is supported and handle both scenarios.
:: by David Ruhmann
:: Hide Commands
@echo off
rem setlocal /?
rem VERIFY OTHER 2>nul
rem SETLOCAL ENABLEEXTENSIONS
@davidruhmann
davidruhmann / Example_Shortcut.bat
Created December 4, 2012 19:08
[Batch] Create a shortcut in batch using WSH (WScript)
:: Example Usage for the Shortcut function.
:: Create a shortcut in batch using WSH.
:: by David Ruhmann
:: Hide Commands
@echo off
:: Isolate Scope
setlocal
@davidruhmann
davidruhmann / Example_WindowsVersion.bat
Created December 6, 2012 23:45
[Batch] Get and Verify the version of Windows
:: Get and Verify the version of Windows
:: by David Ruhmann
:: Hide Commands
@echo off
echo.
call :WindowsVersion xMajor xMinor
echo.%xMajor%
echo.%xMinor%
@davidruhmann
davidruhmann / Admin.bat
Last active May 7, 2023 06:37
Check if user has Administrator privileges and request them if needed.
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:Admin <Return> [Needed] [Success]
:: Check for Administrator privileges and request privileges if Needed 'true'.
:::: Usage: call :Admin xReturn true
:: Return success value, if user is Admin. Default `true` if Success not set.
setlocal
set "xVBUAC=%Temp%\AdminUAC.vbs"
set "xSuccess=true"
set "xAdmin=false"
if not "%~3"=="" set "xSuccess=%~3"
@davidruhmann
davidruhmann / CopyAllDrivesToExternal.bat
Created December 26, 2012 20:11
[Batch] Copy contents for all of a systems drives onto a specified external HDD.
@echo off
setlocal EnableDelayedExpansion
rem Loop through all of the drives to find the external HDD
for %%D in (A B C D E F G H I J K L M N O P Q R S T U V W X Y Z) do (
for /f "tokens=5" %%S in ('vol %%~D:') do set "xSerial=%%S"
if "%xSerial%"=="ABCD-1234" (
rem TODO Specify the exact target copy base location that you want.
set "xTarget=%%~D:\%ComputerName%"
)
@davidruhmann
davidruhmann / ParsePipeSeparatedValuesFile.bat
Created January 10, 2013 15:42
[Batch] Parse a file with pipe | delimiters.
@echo off
setlocal EnableExtensions DisableDelayedExpansion
for /F "delims=" %%Z in ('type file.txt') do (
set "xLine=|%%Z"
call :Parse xLine
)
endlocal
pause >nul
goto :eof