Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi there.
I have an application where I wrote an execute statement that just deletes all the QVD files within a folder. I am aware I could set them to null but I really need to delete them. We have a process that outputs a single QVD for each client and then I later combine them. Once they are combined I need to delete them as that client might not have a QVD outputted on the next run.
My issue is that my execute statement works fine for me (the author) but doesnt work so well for other users (including the QMC). I have compared settings between my user and this other and they are identical. He can also run the execute command in CMD.exe so I know it isn't a problem with his account. There seems to be some holdup on the Qlik side that I just cant figure out. If I run the code on his application, it works for me.
Here is the code:
To execute external commands/batches they need to be enabled within the user-properties (in tab security) and in the document-properties (tab settings below the script-editor window).
Further the users need the approriate access-rights and the path must be valid and available for the users. You wrote that you checked this but if it don't work the reason is most often here to be found and could be sometimes quite tricky ... (read/changing rights are not delete-rights, syntax if the path is dynamically created, different drive-letters, unc-path - AFAIK cmd.exe is here sensitive, ... and similar stuff). Therefore I wouldn't discard it to easily.
- Marcus
Yes both user properties and document properties (as you described above) are set for both users. When the user in question runs the code, the CMD window splashes the screen quickly yet no files are deleted from the path. When my user opens the same .qvw, and runs the same code, the CMD window splashes the screen and the files are deleted.
The code is using relative paths (..\..\) but again, the file is not moved between user runs, file is stored on a network server.
If the user who has the issue, copies the EXECUTE command and pastes it into CMD.exe, it runs and deletes the files just fine.
So why doesn't it work within Qlik for this user?
EDIT - Marcus, I re-read your comment and the user has permission to manually delete the files from the folder (outside of Qlik).
Hi, the both user have the same windows version?
version yes (10 Pro), builds no. My account is two builds behind (it works for me). Compared QV versions and they are identical.
For testing to get any message about what's happening remove the /c parameter and/or push the cmd-results into a log-file - means something like:
EXECUTE cmd.exe /c del "\\<server>\<folder>\*.qvd" >"path\log-file.txt"
- Marcus
I removed the /c and the command prompt just shows the local folder where my QVW is, NOT the path where my QVD is stored.
When I tried to add the redirect to the log file, I was unable to get that to work.
*I should also say that I attempted this from the machine where the original execute statement works without issue.
Any idea on how to get the log file to work? I tried to search around but wasnt able to find anything that I was doing wrong.
The reason may your unc-path. AFAIK cmd struggles in some cases with it. I never tried it with del-statement but by the copy-statement I know it doesn't worked - means you need to apply a drive-letter for your path or you need another statement. In regard to copy the following worked:
execute cmd.exe /c copy "D:\Path1\File..." "D:\Path2\File...";
or
execute cmd.exe /c xcopy "\\Server\Path1\File..." "\\Server\Path2\File...";
I assume for del it's similar - means there are also possibilities to bypass it, maybe even with xcopy or robocopy or something else.
- Marcus
Only other thing I have Chase is the following, will allow you to double-check things:
Cheers,
Brett