Action Failed: delete SWD_Download

Hi Guys

I have an action that is based on a software package and the main command is a batch file. In the batch file it takes ownership of a file in System32 and then runs an .exe file with PowerShell. At the end of the action script, it always fails on a particularly part, but I have no idea why… It does the job tho, the batch and the .exe did run without a problem, but BigFix gives as status Failed:

Action Script Execution Detail   


Completed
// ---------------------------------------------EDITING 
INSTRUCTIONS---------------------------------------------------------------------

Completed
// When editing this task through the Manage Software Distribution 
Packages dashboard, you will have the option to preserve any custom edits you 
make to this action.

Completed
// If you select the option to preserve custom edits, only areas bound 
by the comment markers 'Preparation Marker', 'Command Marker' and 'Closing 
Marker' are updated.

Completed
// To ensure that all your custom Action Script changes can be 
preserved, only make changes to areas that are not bound by the comment 
markers.

Completed
// Removing the comment markers may result in the Action Script not 
updating correctly during the next edit.

Completed
// See KB Article swg21668807 
(http://www-01.ibm.com/support/docview.wss?uid=swg21668807) for more 
information.

Completed
// 
--------------------------------------------------------------------------------------------------------------------------------------

Completed
//**Begin Preparation Marker

Completed
// Download all specified files

Completed
begin prefetch block

Completed
add prefetch item name=603D4C5D4A1A15D4AC5D43B9A5F2082E11192389 
sha1=603d4c5d4a1a15d4ac5d43b9a5f2082e11192389 size=172 
url=SWDProtocol://127.0.0.1:52311/Uploads/603D4C5D4A1A15D4AC5D43B9A5F2082E11192389/ApnDatabase.cmd.bfswd 
sha256=5e1a9ae6aeb60d9c39edfce6b4b6b63b6fa5b9be3c2f8423a9818a8b305c1c16

Completed
add prefetch item name=F8F406FEAC308B230A212010C3B1799C6B1EE3BD 
sha1=f8f406feac308b230a212010c3b1799c6b1ee3bd size=194048 
url=SWDProtocol://127.0.0.1:52311/Uploads/F8F406FEAC308B230A212010C3B1799C6B1EE3BD/ApnDatabase.exe.bfswd 
sha256=73f8857ea60b9020d0abeb360843f8c18054b0514b1e03ced84f28b9d0097fb3

Completed
end prefetch block

Completed
// All SWD files will go into a folder in the clients __BESData folder. 
This folder gets cleared on every restart.

Completed
parameter "baseFolder" = "__Download/"

Completed
// Move files into subfolders and unescape file names

Completed
move "__Download/603D4C5D4A1A15D4AC5D43B9A5F2082E11192389" "{parameter 
"baseFolder"}ApnDatabase.cmd"

Completed
move "__Download/F8F406FEAC308B230A212010C3B1799C6B1EE3BD" "{parameter 
"baseFolder"}ApnDatabase.exe"

Completed
// Log setup

Completed
parameter "mainSWDLogFolder" = "{parent folder of client folder of 
current site}/__Global/SWDDeployData"

Completed
folder create "{parameter "mainSWDLogFolder"}"

Completed
parameter "logFile" = "SWD_DeploymentResults.log"

Completed
//**End Preparation Marker

Completed
delete __createfile

Completed
parameter "outsideOfClientFolder" = "{name of drive of client folder of 
current site}/SWD_Download/__Download"

Completed
folder delete "{parameter "outsideOfClientFolder"}"

Completed
folder create "{parameter "outsideOfClientFolder"}"

Completed
parameter "logFolder" = "{name of drive of client folder of current 
site}/SWD_Download"

Completed
// Run setup process

Completed
delete run_{id of active action}.bat

Completed
// Use .bat to set working directory to packages root, for setup 
command.

Completed
createfile until _end_

Completed
@ECHO OFF

Completed
cd "{parameter "outsideOfClientFolder"}"

Completed
rem // See comments at the beginning of this action for an explanation 
of the comment markers.

Completed
set DATESTAMP=%DATE:~10,4%_%DATE:~4,2%_%DATE:~7,2%

Completed
set DATEANDTIME=%DATESTAMP% %time%

Completed
echo %DATEANDTIME% >> "{parameter "logFolder"}/{parameter 
"logFile"}"

Completed
echo Action ID: {id of active action} >> "{parameter 
"logFolder"}/{parameter "logFile"}"

Completed
rem //**Begin Command Marker

Completed
echo Command: ApnDatabase.cmd >> "{parameter 
"logFolder"}/{parameter "logFile"}"

Completed
set errorlevel=

Completed
ApnDatabase.cmd >> "{parameter "logFolder"}/{parameter "logFile"}" 
2>&1

Completed
set SWDExitCode=%errorlevel%

Completed
rem //**End Command Marker

Completed



Completed
echo Return code: %SWDExitCode% >> "{parameter 
"logFolder"}/{parameter "logFile"}"

Completed
echo. >> "{parameter "logFolder"}/{parameter 
"logFile"}"

Completed
exit %SWDExitCode%

Completed
_end_

Completed
move __createfile run_{id of active action}.bat

Completed
waithidden cmd /C copy /Y run_{id of active action}.bat "{parameter 
"outsideOfClientFolder"}"

Completed
waithidden cmd /C xcopy /Y /E "{pathname of client folder of current 
site}/__Download" "{parameter "outsideOfClientFolder"}"

Completed
// You will not be able to stop or take action on an applicable BigFix 
Client until your installer completes.

Completed
// So ensure no user input is required.

Completed
// If your package absolutely must interact with the user, replace 
'override wait' with 'override run' and 'wait' with 'run'.

Completed
override wait

Completed
runas=currentuser

Completed
completion=job

Completed
hidden=true

Completed
wait "{parameter "outsideOfClientFolder"}/run_{id of active 
action}.bat"

Completed
waithidden cmd /C type "{parameter "logFolder"}\{parameter "logFile"}" 
>> "{parameter "mainSWDLogFolder"}/{parameter "logFile"}"

Completed
delete "{parameter "logFolder"}/{parameter "logFile"}"

Failed
folder delete "{name of drive of client folder of current 
site}/SWD_Download



//**Begin Closing Marker



// Get the return code of the previous action.



parameter "returnCode" = "{exit code of action}"



// Task will now exit.



exit {parameter "returnCode"}



//**End Closing Marker

Does anybody have an idea why and what to do about it? We did upload a couple of large packages the last couple of days, may that be the problem? But that was last week, so normally it shouldn’t have any effect on today I think… Or am i wrong?
As always, thanks for your help!

Greetings

“folder delete” will fail if there are files in use that it can’t delete, have you checked that folder after the failure to see if there are any files or folders still in there?

1 Like

You may need to add a pause while statement to add a little delay before attempting the folder delete.

Hi Sean

Sorry for the late reply, was a bit busy.

Yes, the folder is empty, i checked that. The line above the Failed code indicates that it is completed and it is really deleted… So the folder has no content and is 0 bytes.

thanks jgstew, i’ll try that one!