Just as info sharing, an approach I like to use for looping through commands and avoid creating batch files is to build a parameter of the files to be executed then loop those using a CMD “for” command, eg
parameter "mycommands" = "{"%22" & (concatenation "%22,%22" of (pathnames of files "OneDriveSetup.exe" of folders of folder "OneDrive" of folder "Appdata\Local\Microsoft" of folder (name of current user) of folder "C:\Users")) & "%22"}"
override wait
hidden=true
runas=currentuser
wait cmd.exe /c "for %a in ({parameter "mycommands"}) do (%a /uninstall)"
I would use the debugger to test first replacing the /c with /k and maybe use an echo command so I can see the CMD output is syntaxly correct before actaully running it, i.e.
parameter "mycommand" = "{"%22" & (concatenation "%22,%22" of (pathnames of files "OneDriveSetup.exe" of folders of folder "OneDrive" of folder "Appdata\Local\Microsoft" of folder (name of current user) of folder "c:\users")) & "%22"}"
wait cmd.exe /k "for %a in ({parameter "mycommand"}) do (echo %a /uninstall)"
