Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
cbushey1
Creator III
Creator III

Script execute statement doesn't work for some users

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:

EXECUTE cmd.exe /c del "\\<server>\<folder>\*.qvd" 
 
*Obviously I have omitted my server and folder names here but I can assure you they are correct paths (it works for me remember).
Labels (5)
8 Replies
marcus_sommer

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

cbushey1
Creator III
Creator III
Author

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). 

uroboros
Creator
Creator

Hi, the both user have the same windows version?

cbushey1
Creator III
Creator III
Author

version yes (10 Pro), builds no. My account is two builds behind (it works for me). Compared QV versions and they are identical.

marcus_sommer

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

cbushey1
Creator III
Creator III
Author

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.

marcus_sommer

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

 

Brett_Bleess
Former Employee
Former Employee

Only other thing I have Chase is the following, will allow you to double-check things:

https://help.qlik.com/en-US/qlikview/April2020/Subsystems/Client/Content/QV_QlikView/Scripting/Scrip...

Cheers,
Brett

To help users find verified answers, please do not forget to use the "Accept as Solution" button on any post(s) that helped you resolve your problem or question.
I now work a compressed schedule, Tuesday, Wednesday and Thursday, so those will be the days I will reply to any follow-up posts.