Skip to content

Instantly share code, notes, and snippets.

@davidruhmann
davidruhmann / RandomGen.bat
Last active December 12, 2015 02:18
[Batch] Random Character Generator
@echo off
setlocal EnableExtensions
:: Example Usage
call :RAND CHA
echo %CHA%
endlocal
pause >nul
exit /b
@davidruhmann
davidruhmann / ExtractURL.bat
Last active May 7, 2023 02:15
[Batch] Extract the URL from a bunch of .url shortcut files.
@echo off
setlocal EnableExtensions
for %%A in (*.url) do (
for /f "usebackq tokens=1,* delims==" %%X in ("%%~fA") do (
if /i "%%X"=="Url" (
echo(%%~nA = %%Y>>list.txt
echo(%%Y
)
)
)
@davidruhmann
davidruhmann / Connect.bat
Last active May 8, 2022 18:46
[Batch] Network File Share Connection Scripts
:: Hide Commands.
@echo off
title Network Connect
:: Disconnect Current Connections.
if exist Disconnect.bat call Disconnect.bat
:: Get User Credentials.
set /p xUsername=^> Please Enter Your Username:
::set "xPassword="
@echo off
setlocal EnableDelayedExpansion
if "%~1"==":::" goto :spinnerThread
:menuLoop
<nul set /p menu=Select menu[1 or 2]=
call :GetKey
echo(
echo Pressed '!key!'
if !key!==1 call :menu1
@davidruhmann
davidruhmann / GitCheetah.bat
Created February 13, 2013 20:44
[Batch] Remove Git Cheetah Context Menu Items
cd "C:\Program Files (x86)\Git\git-cheetah"
regsvr32 -s -u git_shell_ext64.dll
:: http://alensiljak.blogspot.com/2012/09/remove-git-explorer-extensions-cheetah.html
@davidruhmann
davidruhmann / .gitignore
Last active December 13, 2015 17:38
[Batch] Clean Visual Studio Project
#################
## Eclipse
#################
*.pydevproject
.project
.metadata
bin/
tmp/
*.tmp
@davidruhmann
davidruhmann / strLen.bat
Created February 14, 2013 03:14
[Batch] String Length by Squashman
@echo off
set str=TEST
set string1=%str:~0,2%
echo %string1%
CALL :strLen string1 len
echo Length is %len%
pause
@davidruhmann
davidruhmann / 14939327.bat
Last active December 13, 2015 23:09
[Batch] StackOverflow answer backup
Something like this should work. It will loop through each .mf file and append all of its contents into big.one skipping the date on all but the first file.
:: Does not work since x will only expanded once and skip=0 is invalid.
setlocal EnableExtensions
set "x=0"
for %%A in (*.mf) do (
for /f "usebackq skip=%x% delims=" %%B in ("%%~fA") do (
echo(%%B>>big.one
)
@davidruhmann
davidruhmann / ExtractVariableSet.bat
Last active May 7, 2023 01:49
[Batch] Extract Variable Set
@echo off
setlocal EnableExtensions EnableDelayedExpansion
:: Setup
set "ResultsFolder=results"
set "ExportFile=output.txt"
:: Verify that the Results folder exists
if not exist "%ResultsFolder%\*" md "%ResultsFolder%"
set "OutputFile=%ResultsFolder%\%ExportFile%"
@davidruhmann
davidruhmann / ecol.bat
Created February 26, 2013 16:12
[Batch] Print colored text in batch script with debug.exe by bl8086 http://pastebin.com/bzYhfLGc
@echo off
setlocal enabledelayedexpansion
set /a _er=0
set /a _n=0
set _ln=%~4
goto init
:howuse ---------------------------------------------------------------