Forums before death by AOL, social media and spammers... "We can't have nice things"
|    alt.msdos.batch.nt    |    Fun with Windows NT batch files    |    68,980 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 67,188 of 68,980    |
|    Herbert Kleebauer to John Gray    |
|    Re: Running a batch file from the %temp%    |
|    18 Apr 18 21:43:08    |
      From: klee@unibwm.de              On 18.04.2018 08:46, John Gray wrote:              > The only problem I cannot circumvent is how to close down the STARTed       > child window - the final line of the batch file does not cause this to       happen.       > commands in CAPITALS are for debugging.              Instead of               cd /d %temp% & start "" %~n0.bat              use:               cd /d %temp% & start "" cmd /c %~n0.bat              or:               cd /d %temp% & %~n0.bat                     In the second case you have to avoid the () in the       if statement:              if /i "%cd%"=="%temp%" goto :temp        REM we are running from original location %cd%        copy %~n0.bat %temp%        REM copy RemoveDrive.exe %temp%        cd /d %temp% & %~n0.bat       :: ECHO Finishing the original BATch file...       :: PING -n 21 127.0.0.1 > nul       :: endlocal & exit /b 0              :temp       :: we reach here if running the copied BATch file              > @echo off       > :: this BATch file called, arbitrarily, $RunOnTemp.bat       > :: is copied to %temp% and run from there       > setlocal       > ECHO Hello from the top of the BATch file %~n0.bat!       > ECHO %%0 is %0       > ECHO %%cd%% is %cd%       > ECHO %%temp%% is %temp%       > PAUSE       > :: determine whether we are running in       > :: * the original BATch file, or       > :: * its copy in the %%temp%% folder       > if /i not "%cd%"=="%temp%" (       > REM we are running from original location %cd%       > copy %~n0.bat %temp%       > REM copy RemoveDrive.exe %temp%       > cd /d %temp% & start "" %~n0.bat       > ECHO Finishing the original BATch file...       > PING -n 21 127.0.0.1 > nul       > endlocal & exit /b 0       > )       > :: we reach here if running the copied BATch file       > ECHO the required BATch file work is done below       > setlocal enabledelayedexpansion       > ECHO.       > ECHO etc, etc...       > ECHO.       > ECHO Hello at end of BATch file %~n0.bat       > PAUSE       > endlocal       > :: this EXIT command does not cause the child       > :: Command Prompt window to terminate.       > :: Neither does goto :eof WHY?       > exit /b 0       >       >              --- SoupGate-Win32 v1.05        * Origin: you cannot sedate... all the things you hate (1:229/2)    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca