Page 2 of 2

Posted: Fri Feb 16, 2007 5:23 pm
by ricardo
Joakim Christiansen wrote:

Code: Select all

If ProgramParameter(0)
  DeleteDirectory(Left(ProgramParameter(0),Len(ProgramParameter(0))-1),"*.*",#PB_FileSystem_Recursive|#PB_FileSystem_Force)
  comspec$=Space(255): GetEnvironmentVariable_("comspec",comspec$,255)
  RunProgram(comspec$,"/c del "+#DQUOTE$+GetPathPart(ProgramFilename())+#DQUOTE$,"")
Else
  If MessageRequester("Uninstall","Are you shure you want to completely remove this folder and all the files in it?",#MB_ICONQUESTION|#PB_MessageRequester_YesNo) = #PB_MessageRequester_Yes
    CopyFile(ProgramFilename(),GetTemporaryDirectory()+"TVUninstall.exe")
    RunProgram(GetTemporaryDirectory()+"TVUninstall.exe",#DQUOTE$+GetPathPart(ProgramFilename())+#DQUOTE$,"")
  EndIf
EndIf
Tried running it from the temp-directory like this and then delete the directory I gave it in a parameter, but it didn't work.
In first place, i guess it will fails because your program is running and you can't delete a directory that have a running file.

And using "If ProgramParameter(0) " its a little dangerosu because some exe receives a program parameter many times, per example when running from a shortcut, etc.

I think you have to make sure that receives certain parameter before trying to delet anything.

One more point is that you should not delete the whole directory in which your app is running... and what about if for any reason people moves the executable to C:\?????

A uninstall must use some ini file or something that tells WHAT files and directories you create and you can only delete those ones. Can't asume that the directory in which the program is running is the same, its dangerous, very dangerous.

Posted: Fri Feb 16, 2007 11:44 pm
by Joakim Christiansen
ricardo wrote:One more point is that you should not delete the whole directory in which your app is running... and what about if for any reason people moves the executable to C:\?????
Yeah, you got a point there!