Xeijin Posted February 10, 2007 Share Posted February 10, 2007 I'm trying to create a Batch File that will perform a few cleanup operations such as deleting shortcuts/log files etc.However I'm having a few problems, the batch file dosen't seem to be doing anything. I have a feeling its to do with my IF EXIST statements and using more than one in the same instance, but after some googling, I've been unable to find a solution. I'm sure its pretty easy but I dont think my google search terms are picking it up.Another problem is deleting the 'install' folder and subfolders, with the del command I'm able to delete the folder and subfolder contents, but not the folders and subfolders themselves! It's pretty late, and I'm sure I'm missing something simple, but I'm stumped right now I've attached my cleanup.bat file incase anyone can help out.// Xeijincleanup.txt Link to comment Share on other sites More sharing options...
war59312 Posted February 10, 2007 Share Posted February 10, 2007 (edited) Best way to remove Install folder:SET KEY=HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceExREG ADD %KEY% /V TITLE /D "Windows Install Is Finally Done" /fREG ADD %KEY%55 /VE /D "Removing Windows Install Folder" /fREG ADD %KEY%55 /V 1 /D "cmd /C RD /S /Q %systemdrive%\Install" /fstart rundll32.exe iernonce.dll,RunOnceExProcessAnd to the end of any script right before EXIT. Edited February 10, 2007 by war59312 Link to comment Share on other sites More sharing options...
jbm Posted February 10, 2007 Share Posted February 10, 2007 Open a command window and type if /? or any other dos command to find how to use it.You either need it all on the same line or use ( ) like thisIF EXIST "*.log" DEL "*.log" ELSE ( IF EXIST "*.exe" DEL "*.exe" ELSE ( CD "%USERPROFILE%\Desktop" )) Link to comment Share on other sites More sharing options...
Yzöwl Posted February 10, 2007 Share Posted February 10, 2007 As well as looking at correct IF and ELSE usage, the script could be reduced considerably too.Have you noticed that in your different profiles, you are performing the same tasks?, that could effectively be carried out in a for loop.Here's a quick untested example of a batch file which should do everything you need:@FOR %%? IN (CMDOW.EXE) DO @IF "%%~$PATH:?" NEQ "" ( @%%~$PATH:? @ /HID) ELSE (@ECHO OFF)FOR /D %%? IN ("%ALLUSERSPROFILE:\ALL USERS=%\*") DO CALL :C_ "%%?"2>NUL (DEL %SYSTEMDRIVE%\NVLOG.TXT RD/S/Q %SYSTEMDRIVE%\INSTALL)GOTO :EOF:C_PUSHD %12>NUL DEL/F/Q *.EXE *.LOG DESKTOP\*.*POPD &GOTO :EOF Link to comment Share on other sites More sharing options...
Xeijin Posted February 10, 2007 Author Share Posted February 10, 2007 @war59312: Thanks I didn't know about the RD command @jbm: I did try that out but it didn't seem to work for me?? Doing pretty much the same thing as it was doing before.@Yzowl: Thanks Yzowl this is the script I'm using now Even more useful as it seems to delete it for other users as well!! Though I have no idea what it's doing, it seems to work!Thanks Again,// Xeijin Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now