Any idea why my folder delete does not happen under appdata?

I’m trying to delete a folder under appdata for the logged on user, who is present on the pc, always.

I started with this this:

// Record the current user name
parameter “CurrentUserName” = “{name of logged on user}”

// delete folder in user’s profile
Rundetached cmd.exe /c RD “c:\Users\ {parameter “CurrentUserName”}\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Departmental Apps” /s /q

nothing fails but the folder is still there… I checked in QNA and the action line with the parameter resolves to the proper path with the user name. I also tried folder delete, tried creating a batch file and running that, running as current user also… It never fails but the folder is never getting deleted. It just contains shortcuts/links…

If I type the same command in dos, it works… If I make a batch file and copy it locally (with %appdata% for the path of the logged on user) by hand or via QNA in the action debugger, it works. In Bigfix for real, even with runascurrent user for context, nope… Completes with exit code 2 and did not work with the local batch file scenario, or just completes happily and did not delete the folder using the above action script.

Is it the missing backslash between Users\{parameter "currentusername"} ?

Nah sorry, that’s just a typo from the copy… Running in QNA in I can see a fully formed line that works… I can copy that line into a dos window and it runs fine…

Seems context related… For now I’m using a batch file and I run it as current user and it seems to work better, but not on all machines (some have trickier login issues). I would prefer not using a batch file and the above should work…

The parameter containing blank to cmd.exe may be the cause of the problem.
Have you tried folder delete (https://developer.bigfix.com/action-script/reference/file/folder-delete.html) rather than cmd.exe rd?