I would like to save my input for %x% to the Batch file once I type it in the command prompt. Please see below.
@ECHO OFF
TITLE Access to OST Documents for t
@echo off
call :getvar
if not "%x%" == "" goto :continue
REM var not set; ask user:
REM insert your input code and verification here
REM write it to the end of this batch:
echo set "x=%x%">>"~f0"
:continue
REM rest of your code
REM the following line should be the very last line in this batch (but WITH a CRLF):
:getvar
The call :getvar
tries to set the variable (comes back empty for the first run)
The if
line checks, if empty (then the user gets asked)
echo set "x=%x%">>"~f0"
is the key here. It adds the set command
to the batch file (%~f0
is the batch file's full name), so
call :getvar
comes back with the previously set variable %x%