I am attempting to create a script that will assist in select software installation from a large pool of software on newly imaged PCs. I have the script itself done, but the issue is is requires a flash drive to run, and those are in short supply, especially when doing multiple PCs at once. I created a script to copy the resource files needed to run the main batch script to %TEMP%\MyScript so I can run locally and not off of the flash drive, but I am having difficulty with the cleanup. A cleanup script runs (From %TEMP% that removes the %TEMP\MyScript successfully, but when deleting itself, the script errors out and returns to CMD.
Here are the commands I am using
<--OUTPUT REMOVED-->
ECHO ======= PRESS ANY KEY TO EXIT =======
PAUSE > NUL
START %TEMP%\CleanUp.bat
At this point CleanUp.bat runs:
@ECHO OFF
ECHO Cleaning up install files...
ECHO.
ECHO Removing desktop shorcut...
DEL "%USERPROFILE%\Desktop\Link to Software Installer.lnk" > NUL
ECHO.
ECHO Removing %TEMP%\MyScript
RMDIR /S /Q %TEMP%\MyScript\
ECHO.
ECHO Removing CleanUp utility...
REM Delete self on Exit
DEL /f/q "%~0" | exit
After the Removing CleanUp Ultility... text shows, it then reads "The Batch File cannot be found." and returns to CMD in the %TEMP% location. Everything is removed, but I need the script to exit and close the CMD window.
Here are the commands I am using
<--OUTPUT REMOVED-->
ECHO ======= PRESS ANY KEY TO EXIT =======
PAUSE > NUL
START %TEMP%\CleanUp.bat
At this point CleanUp.bat runs:
@ECHO OFF
ECHO Cleaning up install files...
ECHO.
ECHO Removing desktop shorcut...
DEL "%USERPROFILE%\Desktop\Link to Software Installer.lnk" > NUL
ECHO.
ECHO Removing %TEMP%\MyScript
RMDIR /S /Q %TEMP%\MyScript\
ECHO.
ECHO Removing CleanUp utility...
REM Delete self on Exit
DEL /f/q "%~0" | exit
After the Removing CleanUp Ultility... text shows, it then reads "The Batch File cannot be found." and returns to CMD in the %TEMP% location. Everything is removed, but I need the script to exit and close the CMD window.