Jump to content

Batch File Uninstaller


Recommended Posts

i downloaded this program a few days ago, but it only was a program without an installation file

so i thought:

lets make an Start Menu folder for it, and a Program Files folder, no problems there

but i thought it would be nice if i could uninstall it so i dont have to manually delete it

so i thought of creating a batch file which would remove the Start Menu and Program Files folder

but that is where the problems occure:

when i run my dos batch file, it only deletes the files inside the File_Renamer folder

here is my batch file [uninstall.bat]

@echo off
echo Uninstalling...
@echo off
cd C:\Documents and Settings\All Users\Menu Start\Programma's
DEL File_Renamer

cd C:\Program Files
DEL File_Renamer

echo Done!
@echo off
pause
exit

does someone know how to make it delete the folder, instead of the files inside?

and how can i make it that it doesnt asks me to delete the files, but just does it? [is that the /Q addition?]

please help

thanks

Link to comment
Share on other sites

Your code will delete the folder itself, not the files inside. To delete the files inside, you must specify the file or use the *.* for all.

I know of a command called DELTREE which will delete any folder tree underneath the tree specified. For exmaple:

C:\Folder1\Folder2\

--------------\File1

------------------------\Folder3\File2

runing the command deltree C:\folder1\folder2 will delete folder3, file2 and file1. I hope my diagram makes sense.

Maybe this will help:

http://www.computerhope.com/msdos.htm

Link to comment
Share on other sites

so if i would like to apply it, i should use:

DELTREE C:\Documents and Settings\All Users\Menu Start\Programma's\File_Renamer /Y

DELTREE C:\Program Files\File_Renamer /Y

cd C:\Documents and Settings\All Users\Bureaublad
DEL File_Renamer.Ink /Q

btw: my current code does remove the files from a folder, but leaves the folder where it is...

Link to comment
Share on other sites

The use of DELTREE or RMDIR depends on the OS.

RMDIR!!!! That's the one I was thinking of! Boy it's been a while since I used dos. :blink:

Regarding @ECHO...

@ECHO OFF

will turn off the location of where the file is run from. For example C:\

ECHO OFF

will turn off every line, until the ECHO ON command is used.

(I think) B)

Link to comment
Share on other sites

ok, that worked to remove the folder, but i still cant remove the folder where the uninstall.bat file is located... [it wont get deleted > no error message]

i think that is because it deletes itself before it can remove the folder...

is there a ay to solve this?

Link to comment
Share on other sites

i know, i already used that:

@echo off
echo Uninstalling...
@echo off
pause

RD "C:\Documents and Settings\All Users\Menu Start\Programma's\File_Renamer" /Q

DEL "C:\Documents and Settings\All Users\Bureaublad\File_Renamer.Ink" /Q

RD "C:\Program Files\File_Renamer" /Q /S

RD "C:\Program Files\File_Renamer" /Q

echo Done!
@echo off
pause
exit

when i move the last t20 RD command lines more up, everything after that isnt done > it deletes itselve...

is there a way to fix that?

Link to comment
Share on other sites

just dont delete the file untill your fully done...

so what i would do:

copy "the uninstaller" c:\documents and settings\U S E R\temp\uninstaller.bat

c:\documents and settings\U S E R\temp\uninstaller.bat

INSERT DELETE CODE

echo Done

pause

del c:\documents and settings\U S E R\temp\uninstaller.bat

Link to comment
Share on other sites

but doesnt that require you to swith to the other batch file and run it?

how can i run another batch file from a batch file...?

or do i just understand it wrong?, 'cause when you copy the file nothing will happen, you will only copy the file, so you also need to run it, but how do you do that?

wouldnt you have to know how to edit the content of that batch file?

Link to comment
Share on other sites

if you copy the batch file (and makes sure the batch file only contains absolute path names, instead of relative i.e. c:\dir\anotherdir\file.txt instead of \anotherdir\file.txt )

And then just call the file (which i showed in the second line:

c:\documents bla bla bla \uninstaller.bat

the batch file should be run (and keep running, even if its caller is deleted).

Link to comment
Share on other sites

ok this is what i have now:

@echo off
echo Uninstalling...
@echo off
pause

COPY "C:\Program Files\map\Uninstall.bat" "C:"

cd C:
Uninstall.bat

RD "C:\Documents and Settings\All Users\Menu Start\Programma's\map" /Q

DEL "C:\Documents and Settings\All Users\Bureaublad\map" /Q

RD "C:\Program Files\map" /Q /S

RD "C:\Program Files\map" /Q

DEL "C:\Uninstall.bat"

echo Done!
@echo off
pause
exit

but i cant seem to run the C:\Uninstall.bat file

how can i do this

and will this batch file remove:

-the C:\Program Files\map directory

-the map shortcut from the desktop

-the map folder from the start menu

-the uninstall.bat copy from C:

?

Link to comment
Share on other sites

The idea is to move this file to anywhere else then the folder in question.

Then run it.

When it runs, be sure you have the full paths of everything, since relative paths won't work from all directories.

The final line of this file, is to delete itself.

This is the easiest solution, since making it "selfcopy", in case its in the dir, and making it skipping the "selfcopy" when its copied, is a rather complicated thing to explain - but doable!!

And the reason for not deleting the file while in the dir, is to be sure the dir, and all in it is gone, before saying "uninstall complete"...

@echo off

echo Uninstalling...

@echo off

pause

RD "C:\Documents and Settings\All Users\Menu Start\Programma's\File_Renamer" /Q

DEL "C:\Documents and Settings\All Users\Bureaublad\File_Renamer.Ink" /Q

RD "C:\Program Files\File_Renamer" /Q /S

RD "C:\Program Files\File_Renamer" /Q

echo Done!

@echo off

pause

DEL uninstaller.bat

Link to comment
Share on other sites

ok ik improved it a bit again:

@echo off
echo Uninstalling...
@echo off
pause

COPY "C:\Program Files\map\Uninstall.bat" "C:"

START "C:\Uninstall.bat"

RD "C:\Documents and Settings\All Users\Menu Start\Programma's\map" /Q

DEL "C:\Documents and Settings\All Users\Bureaublad\map.ink" /Q

RD "C:\Program Files\map" /Q /S

RD "C:\Program Files\map" /Q

DEL "C:\Uninstall.bat"

echo Done!
@echo off
pause
exit

removes:

-start menu folder

-program files folder contect

doesnt remove:

-program files folder

-desktop shortcut

and i get this window after i run the batch file [attached]

@mcb2001: what is the difference with your code, and my ones, which didnt work?

Link to comment
Share on other sites

Okay, to be honest, i use lower case all the time, to be sure, and the "at" sign @ is useless, if you just run "echo off" in the first line, you get echo turned off, and then its on for the rest of the "program".

"rd" should work - if you use BOTH /S and /Q in order to remove it ALL without asking.

"del" should work - if you use BOTH /F and /Q in order to remove even locked file, without even asking.

"echo" should work (even better with "echo off")

So copy this into a file, when you wanna uninstall the programm, just copy the uninstaller to the desktop, run it, and let it delete everything, including itself...

echo off

echo Uninstalling...

pause

rd "C:\Documents and Settings\All Users\Menu Start\Programma's\File_Renamer" /S /Q

del "C:\Documents and Settings\All Users\Bureaublad\File_Renamer.Ink" /F /Q

rd "C:\Program Files\File_Renamer" /S /Q

rd "C:\Program Files\File_Renamer" /S /Q

echo Done!

pause

DEL uninstaller.bat /F /Q

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy