@echo off
if "%username%"=="" goto GETUSER
echo set fpUser=%username%>"us#rname.bat"
call "us#rname.bat"
del "us#rname.bat" > nul
if not "%fpuser%"=="" goto END 
:: ---------------------------------------------------
:: Get the name of the person logged in
:GETUSER
start /w regedit /e reg.txt HKEY_LOCAL_MACHINE\Network\Logon
type reg.txt | find "Username" > "us#rname.bat"
echo set fpuser=%%1>"username.bat"
call "us#rname.bat"
del "us?rname.bat" > nul
del reg.txt > nul
if not "%fpuser%"=="" goto SETFPUSER
:: ----------------------------------------------------
:: following added 08/23/02 to correct variations in Username 
:TRYAGAIN
start /w regedit /e reg.txt HKEY_LOCAL_MACHINE\Network\Logon
type reg.txt | find "username" > "us#rname.bat"
echo set fpuser=%%1>"username.bat"
call "us#rname.bat"
del "us?rname.bat" > nul
del reg.txt > nul
if not "%fpuser%"=="" goto SETFPUSER
:: ----------------------------------------------------
:JUSTINCASE
echo set fpuser=RTF>"us#rname.bat"
call "us#rname.bat"
del "us?rname.bat" > nul
:: ----------------------------------------------------
:SETFPUSER
md %pfprog%\fp\fp2rtf\temp1
cd %pfprog%\fp\fp2rtf\temp1
:: creates a temp1 directory for the batch file to work in.  
echo handle>"%fpuser%"
dir /B >..\user.txt
del "%fpuser%" > nul
:: outputs the data to a file called user.txt in the working directory
cd..
rmdir temp1
copy %pfprog%\fp\fp2rtf\fragment.bat+user.txt runme.bat > NUL
:: merges pre-prepared fragment containing the text  
:: with the user.txt into runme.bat
:: runme.bat now contains the string "set fpuser=username"
call runme.bat
:: executes the batch file
del runme.bat > NUL
del user.txt > NUL
:: cleanup temporary files
cd %pfprog%\
:END
:: now set the required environmnet variables
set reportn=0
set pfprt=%fpuser%%reportn%.rtf
:: delete the fpuser counter file created by ~\fp\fp2rtf\icount.exe
:: this is done to initialize the counter 
:: if exist "~%fpuser%c.txt" del "~%fpuser%c.txt" > NUL
