PDA

View Full Version : Delete Folder Tree question



NewsArchive
04-13-2009, 07:15 AM
Hi,

this is a snippet from the SB help file about "Delete Folder Tree":

==============
Return Values
If the function succeeds, the %_SB_ERRORCODE% return value is nonzero.
If the function fails, the return value is zero.
==============

But %_SB_ERRORCODE% is always zero, regardless wether SB could delete
the folder or not.

I've checked this with a very simple script:

Delete Tree "c:\abc"
Display Message Box "%_SB_ERRORCODE%" -- ""

Test 1: create the folder in windows explorer and let DB delete the
folder ==> Errorcode = zero

Test 2: create the folder in windows explorer, copy an exe to it and
start this exe. Let SB try to delete the folder. After that, the folder
is still there, but ERRORCODE is also zero.

Can somebody help me?

Thanks.

Markus

NewsArchive
04-14-2009, 01:55 AM
I think you have a classic problem with a global errorcode variable:
Using it any way except assignment to another variable may change the
variable.

Using the following script I get different results with folder empty or
not. (See attachment)

Create Folder "C:\wxyz"
Text File: Create File "C:\wxyz\text.txt"
Delete Tree "C:\wxyz"
Set Variable %V1% to "%_SB_ERRORCODE%"
Delete Files "C:\wxyz\text.txt"
Delete Tree "C:\wxyz"
Set Variable %V2% to "%_SB_ERRORCODE%"
Display Message Box "Delete with file in folder:\nerrorcode is
%V1%\n\n..." -- ""


Message text is actually:

Delete with file in folder:
errorcode is %V1%

Delete with empty folder:
errorcode is %V2%

--
Phil Carroll
http://www.enablingsimplicity.com

NewsArchive
04-14-2009, 05:08 AM
Hi,

the Problem is noot wethere there is a file in it or not! The problem
is, wether the folder could be deleted or not. See the attached demo
project and screenshot.

Markus Zander

NewsArchive
04-14-2009, 05:08 AM
> I think you have a classic problem with a global errorcode variable:
> Using it any way except assignment to another variable may change the
> variable.

The SB6 documentation is incorrect. This function does not return a value
in SB6.

It returns a value in SB7 through %_SB_ERRORCODE%.

--
Friedrich Linder
Lindersoft
www.lindersoft.com
+1.954.252.3910

SetupBuilder "point. click. ship"
Create Windows Vista ready installations in minutes

-- Official Comodo Code Signing and SSL Certificate Partner

NewsArchive
04-15-2009, 01:30 AM
Friedrich,

I wrote and tested my script with SB6-2560. Why do I get different
errorcodes after the deleted and not deleted cases?

--
Phil Carroll
http://www.enablingsimplicity.com

NewsArchive
04-15-2009, 01:30 AM
Phil,

your script does delete the folder with it's first try beacause Delete
Tree also deletes folders with contents. The 1 in your %_SB_ERRORCODE%
variable is from your try to delete the file which is not present (it
was delete by your first "delete tree" statement.

Try to debug your script. I'm not 100% sure. I've never testetd your
script, I've just read it.

Markus

NewsArchive
04-15-2009, 01:31 AM
Markus,

> your script does delete the folder with it's first try beacause
> Delete Tree also deletes folders with contents. The 1 in your
> %_SB_ERRORCODE% variable is from your try to delete the file
> which is not present (it was delete by your first "delete tree"
> statement.
>
> Try to debug your script. I'm not 100% sure. I've never testetd
> your script, I've just read it.

In the version you have (#2566), "Delete Folder Tree..." handles
%_SB_ERRORCODE%.

--
Friedrich Linder
Lindersoft
www.lindersoft.com
+1.954.252.3910

SetupBuilder "point. click. ship"
Create Windows Vista ready installations in minutes

-- Official Comodo Code Signing and SSL Certificate Partner

NewsArchive
04-15-2009, 01:32 AM
Hi Phil,

> I wrote and tested my script with SB6-2560. Why do I get different
> errorcodes after the deleted and not deleted cases?

Because "Delete Folder Tree" does not set %_SB_ERRORCODE% at all, the value
comes from another function call.

--
Friedrich Linder
Lindersoft
www.lindersoft.com
+1.954.252.3910

SetupBuilder "point. click. ship"
Create Windows Vista ready installations in minutes

-- Official Comodo Code Signing and SSL Certificate Partner