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,185 of 68,980    |
|    John Gray to All    |
|    Running a batch file from the %temp% fol    |
|    17 Apr 18 23:46:30    |
      From: jgqued@gmail.com              OBJECTIVE: to copy a batch file to the %temp% folder and run it cleanly from       there.              EXPLANATION: the batch file is held on a USB Flash Drive and is used to       install software on the PC, or copy shortcuts to desktops, or the like.       Copying the batch file to the %temp% folder allows the USB Flash Drive to be       removed cleanly (using Uwe Sieber's RemoveDrive.exe) without having to get the       user to go through the Safely Remove Hardware manual operation              What follows is the current state of my test batch file. Commands in CAPITALS       are for debugging.       Any comments on the method, or suggestions of a better method, would be       gratefully received!              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.              @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