Skip to content

Instantly share code, notes, and snippets.

@davidruhmann
davidruhmann / EchoOnSameLine.bat
Created January 16, 2013 02:36
[Batch] Alternate Method of echoing output onto the same line. No CR+LF !
@echo off
setlocal EnableDelayedExpansion
call :createSub
call :echoWithoutLinefeed "=hello"
call :echoWithoutLinefeed " world"
exit /b
:echoWithoutLinefeed
> txt.tmp (echo(%~1!sub!)
copy txt.tmp /a txt2.tmp /b > nul
@davidruhmann
davidruhmann / MUF15.TXT
Created January 16, 2013 02:42
Microsoft Undocumented Features Version 15
===========================================================================
Date: 07-16-93 (23:51) Number: 9499
From: BEN DAVIS Refer#: NONE
To: ALL Recvd: NO
Subj: The MUF List follows... Conf: DOS6
---------------------------------------------------------------------------
ÿ@ORIGIN :EXECNET N
Hi,
I've decided to post this list here, due to a few begging messages. I
@davidruhmann
davidruhmann / RemoveLastToken.bat
Last active December 11, 2015 04:48
[Batch] Remove the last token form a delimited string array (Tab used as example)
set "Var=%Var%@"
for /f "delims=" %%A in ('echo(%Var: =^&echo(%') do call set "Var2=%%Var: %%A=%%"
set "Var=%Var2%"
:: David Ruhmann
:: http://www.computerhope.com/forum/index.php/topic,135076.msg869228.html#msg869228
@davidruhmann
davidruhmann / WordCount.bat
Last active December 11, 2015 11:59
[Batch] Count the Words used in a file and display the results.
::**Windows Batch**
::This will enumerate every word in a file.
@echo off
setlocal EnableExtensions DisableDelayedExpansion
:: Loop through Lines
for /f "delims=" %%A in (lorum.txt) do (
set "_=%%A"
call :Expand_
@davidruhmann
davidruhmann / FindandReplace.bat
Last active May 7, 2023 05:26
[Batch] Find and Replace loops through text files and replaces search terms with strings.
@echo off
setlocal EnableExtensions DisableDelayedExpansion
:: Find and Replace [Works with Special Characters]
:: by David Ruhmann
:: About
:: This is a proof of concept to illustrate the difficulty and limitations in
:: regards to the batch string replacement functionality. Delayed Expansion was
:: not used as an exercise in showing the most common usage of batch.
@davidruhmann
davidruhmann / HideCMD.bat
Created January 24, 2013 16:57
[Batch] Hidden CMD Window
:: Save this one line of text as file invisible.vbs:
CreateObject("Wscript.Shell").Run """" & WScript.Arguments(0) & """", 0, False
:: To run any program or batch file invisibly, use it like this:
wscript.exe "C:\Wherever\invisible.vbs" "C:\Some Other Place\MyBatchFile.bat"
:: To also be able to pass-on/relay a list of arguments use only two double quotes
@davidruhmann
davidruhmann / DynamicMenu.bat
Last active May 7, 2023 06:29
[Batch] Dynamic Menu
:: Hide Command and Set Scope
@echo off
setlocal EnableExtensions
:: Customize Window
title My Menu
:: Menu Options
:: Specify as many as you want, but they must be sequential from 1 with no gaps.
:: Step 1. List the Application Names
@davidruhmann
davidruhmann / Calendar.bat
Last active December 11, 2015 21:58
[Batch] Gregorian Calendar
:: Gregorian Calendar
:: by David Ruhmann
:: NOTES:
:: Requires date format %Date%="ddd MM/dd/yyyy" to default today's date.
:: This is only a proof of concept that may still have some bugs.
@echo off
:: Example Call
@davidruhmann
davidruhmann / calfaq.c
Created January 30, 2013 15:13
[C] Calendar FAQ Formulas
/*
* CALFAQ version 1.1, 4 April 2008
*
* COPYRIGHT:
* These functions are Copyright (c) 2008 by Claus Tondering
* (claus@tondering.dk).
*
* LICENSE:
* The code is distributed under the Boost Software License, which
* says:
@davidruhmann
davidruhmann / PathEnv.bat
Last active May 8, 2022 18:47
[Batch] Path Environment Variable
:: Loop through the paths listed in the PATH evnironment variable
for %%A in ("%Path:;=" "%") do @echo %%A
:: Do not use setx to set the Path variable, because it will
:: truncate the Path string to a maximum of 1024-5 characters.
:: This is due to the cmd.exe command line length limitations.