Skip to content

Instantly share code, notes, and snippets.

@davidruhmann
davidruhmann / Round.bat
Last active August 29, 2015 13:59
Batch Rounding Example
@echo off
setlocal
call :Round 12345.6 Out
echo %Out%
endlocal
exit /b 0
:Round <Input> <Output>
setlocal
for /f "tokens=1,2 delims=." %%A in ("%~1") do set "X=%%~A" & set "Y=%%~B0"
@davidruhmann
davidruhmann / Expand.bat
Last active August 29, 2015 14:00
[Batch] My Expand Routine
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: This works by exploiting the set and defined commands. If the Var is null,
:: then the set command will fail, the error message is caught, and the defined
:: command will fail because there should NEVER exist a variable named =.
:: Usage: call :Expand A %~1 0
:: The default works by exploiting how commands are parsed. If parameter 1 is
:: empty, then 0 will be passed to the routine as Value.
:: Author: David Ruhmann
:Expand <Var> [Value] [Default]
2>nul set "%~1=%~2"
@davidruhmann
davidruhmann / SO26181747.bat
Created October 3, 2014 17:44
SO26181747.bat
@echo off
:: usage: script.bat [username=%username%]
call :AnyActiveRemoteSessions %~1 %username% && echo Yes || echo No
exit /b 0
:AnyActiveRemoteSessions [Username]
for /f "skip=1 tokens=2,4" %%A in ('query user %~1 ^| find ">"') do call :IsActiveRemoteSession "%%~A" "%%~B" && exit /b 0
exit /b 1
@davidruhmann
davidruhmann / SO26614571.bat
Last active August 29, 2015 14:08
SO26614571.bat
@echo off
call :DisplayRecursiveSubDirectoryInformation %1
exit /b 0
@echo off
setlocal disableDelayedExpansion
if "%~1"=="" (call :recurse ".") else call :recurse %1
@davidruhmann
davidruhmann / SO26787012.bat
Created November 6, 2014 20:00
SO26787012.bat
@echo off
setlocal EnableDelayedExpansion
call :Input MyVar "Enter your string "
call :Write MyVar
echo !MyVar!
set MyVar
endlocal
exit /b 0
:Input <Var> [Prompt]
# Shell script to download Oracle JDK from command prompt / terminal.
# You can download all the binaries one-shot by just giving the BASE_URL.
## Features:
# Resumes a broken [previous] download, if any.
# Renames the file to a proper name with platform adding platform info.
# Downloads all the following from Oracle Website with one shell invocation.
# a. Windows 64 and 32 bit;
# b. Linux 64 and 32 bit; and
# c. API Docs.
@davidruhmann
davidruhmann / launcher_profiles.json
Created December 29, 2014 21:37
Minecraft 1.7.10 Base Launcher Profile
{
"profiles": {
"1.7.10": {
"name": "1.7.10",
"lastVersionId": "1.7.10"
}
},
"selectedProfile": "1.7.10"
}
@davidruhmann
davidruhmann / launcher_profiles.json
Last active August 29, 2015 14:12
forge10.13.2.1230 launcher_profiles.json
{
"profiles": {
"Forge": {
"name": "Forge",
"lastVersionId": "1.7.10-Forge10.13.2.1230"
},
"1.7.10": {
"name": "1.7.10",
"lastVersionId": "1.7.10"
}

Source Drive

If using a batch script, you can obtain the drive letter by using the 0 argument.

echo %~d0

Though if using folder mounts, you will want to keep the folder name as well.

wmic volume where label='Knox' get name

@davidruhmann
davidruhmann / MessageDlg.cpp
Created August 3, 2015 21:00
Visual C++ MFC Message Dialog Class
#include "stdafx.h"
#include "MessageDlg.h"
#include <dcp_colorscheme.h> // GetSchemeBrush
#include <Nursing_MsgAPI_Macros.h> // MSGWRITE*
// Static Value Definitions
#define MIN_HEIGHT 50
#define MIN_WIDTH 50
#define MAX_HEIGHT 500
#define MAX_WIDTH 500