Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I was trying to get the external program task running with a simple .bat file that copies a file to another location. The bat file works when I doubleclick it on the server. It's in a folder the service user can reach
Code in bat file: "COPY Dataset_QS.txt "\\servername\Dataset\" /y"
I have tried a couple of things but can't get it to work. Maybe someone can help.
That both doesn't work. I have also read the information on help.qlik.com about it but that doesn't really help at all.
I get a error message with only a 1. Can't find anything about that online so here I am.
Hello @lauranvh
Yes sorry the "file" on the end of the Parameter field was a mistype.
I've attached a screenshot of what works for me (noting that the folder paths are shared as windows shares)
I think I also saw an 'exit code 1' during testing when it couldn't find the file/folders or .bat.
Since it's quite a long path, have you tried a shorter path less complex path to see if that works?
Hi @lauranvh you should refer to these articles you need to make sure that you include the exit status values for the task as explained in the second article.
Qlik-Sense-Createan external program running a Powershell
How-to-handle-tasks-reporting-wrong-status-when-executing
Hello @lauranvh
I've run a couple of tests and have managed to get this to work in my example to copy a .txt from one server to another shared folder:
You're almost there in your example but try changing these two things:
1. Including the full servername (a windows shared path) to the .bat in the Path field
2. Use the EXECUTE command in the Parameter field before the .bat filename:
e.g.
Path: \\SERVERNAME\etc...\test.bat
Parameter: EXECUTE test.bat
Also note the source and destination folders/path specified above for the .txt files were created as Windows shared folders to make sure they are assessible with the appropriate user permissions (and including the Qlik Sense service account that is running the Sense services as this will need access to them).
FYI this post shows how the same EXECUTE command was used in a Sense script therefore applying similar logic there for this as an external task. https://community.qlik.com/t5/Integration-Extension-APIs/Want-to-Execute-Bat-in-load-Script-in-Qlik-...
Hope that helps you get it working!
Thank you for the replies.
@Jon_B I have tried your solution but I can still not get this to work. I am certain that the serviceaccount can reach the file and the destination.
I have tried both Parameter with "file" at the end and without the "file". I don't think that should be there but I tested that still.
I still get the error with exit code 1.
Any ideas on what I can try?
Hello @lauranvh
Yes sorry the "file" on the end of the Parameter field was a mistype.
I've attached a screenshot of what works for me (noting that the folder paths are shared as windows shares)
I think I also saw an 'exit code 1' during testing when it couldn't find the file/folders or .bat.
Since it's quite a long path, have you tried a shorter path less complex path to see if that works?
@Jon_B Thank you for the last answer.
I fixed it now with the change in the .bat file itself. I didn't have the complete path in there only the filename. Now it runs.
I'll accept your reply as a solution.
Thanks for the follow up @lauranvh happy to hear I could help you out on that.
Hello @lauranvh
One of the problems here is your batch file. A better version would be:
pushd %~dp0
copy /Y *.txt \\dc1\share\txt
popd
EXIT 0
The reason is the folders when you call the file as a External Task are not as in your cmd prompt the "current working directory". So its better to use pushd to move into the folder you have the file and then start copying. You otherwise try to copy the file from C:\windows\system32 where it doesn't exist and end in the (0x1) error.
This file above works as external task in two ways:
simple with Path = C:\temp\test2.bat
or a more advanced approach
Path= "C:\Windows\System32\cmd.exe"
Parameters: /c start "" /b /w "C:\temp\test2.bat"
You can try the same in a Scheduled task in Windows
best regards
Sebastian