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
| { | |
| "profiles": { | |
| "Forge": { | |
| "name": "Forge", | |
| "lastVersionId": "1.7.10-Forge10.13.2.1230" | |
| }, | |
| "1.7.10": { | |
| "name": "1.7.10", | |
| "lastVersionId": "1.7.10" | |
| } |
| { | |
| "profiles": { | |
| "1.7.10": { | |
| "name": "1.7.10", | |
| "lastVersionId": "1.7.10" | |
| } | |
| }, | |
| "selectedProfile": "1.7.10" | |
| } |
| @echo off | |
| :Main <Title> [Destination=CD] | |
| call :DownloadIMDB %1 %2 "%CD%" | |
| exit /b | |
| :DownloadIMDB <Title> <Destination> ~UI/IO | |
| PowerShell -NoProfile -ExecutionPolicy RemoteSigned -Command "$c = New-Object System.Net.WebClient; $c.DownloadString('http://www.omdbapi.com/?t=%~1&plot=full&r=json').Split(',') | ForEach { $_.Split('{') | ForEach { $_.Split('}') | ForEach { $l = $_.ToLower(); If ($l.Contains(([char]0x0022).ToString() + 'title' + ([char]0x0022).ToString())) { $env:_title = $_.Split(([char]0x0022).ToString())[3] } ElseIf ($l.Contains(([char]0x0022).ToString() + 'year' + ([char]0x0022).ToString())) { try { $env:_year = $_.Split(([char]0x0022).ToString())[3].Substring(0,4) } catch { } } ElseIf ($l.Contains(([char]0x0022).ToString() + 'poster' + ([char]0x0022).ToString())) { $env:_poster = $_.Split(([char]0x0022).ToString())[3] } ElseIf ($l.Contains(([char]0x0022).ToString() + 'rated' + ([char]0x0022).ToString())) { $env:_rated = $_.Split(([char]0x0022).ToString())[3] } } } }; Write-Host "$env:_title ($env |
| @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 |
| # 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. |
| @echo off | |
| setlocal EnableDelayedExpansion | |
| call :Input MyVar "Enter your string " | |
| call :Write MyVar | |
| echo !MyVar! | |
| set MyVar | |
| endlocal | |
| exit /b 0 | |
| :Input <Var> [Prompt] |
| @echo off | |
| call :DisplayRecursiveSubDirectoryInformation %1 | |
| exit /b 0 | |
| @echo off | |
| setlocal disableDelayedExpansion | |
| if "%~1"=="" (call :recurse ".") else call :recurse %1 |
| @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 | |
| :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: | |
| :: 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" |