Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
lauranvh
Partner - Creator
Partner - Creator

Qlik Sense Enterprise QMC - External program task doesn't run with .bat file

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.

  • Tried to put the script in the Path without any parameters
  • Tried to put the cmd.exe into the Path and the script location in the parameters

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.

Labels (2)
1 Solution

Accepted Solutions
Jon_B
Support
Support

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?

ExternalCopytask.png

 

 

Please, remember to "like" the post and mark the thread as solved once getting the correct answer

View solution in original post

7 Replies
Eugene_Sleator
Support
Support

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 


Jon_B
Support
Support

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!

Please, remember to "like" the post and mark the thread as solved once getting the correct answer
lauranvh
Partner - Creator
Partner - Creator
Author

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?

Jon_B
Support
Support

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?

ExternalCopytask.png

 

 

Please, remember to "like" the post and mark the thread as solved once getting the correct answer
lauranvh
Partner - Creator
Partner - Creator
Author

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

Jon_B
Support
Support

Thanks for the follow up @lauranvh happy to hear I could help you out on that.

Please, remember to "like" the post and mark the thread as solved once getting the correct answer
Sebastian_Linser

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 

Sebastian_Linser_0-1664785257236.png

or a more advanced approach

Path= "C:\Windows\System32\cmd.exe"

Parameters: /c start "" /b /w "C:\temp\test2.bat"

Sebastian_Linser_5-1664785410294.png

You can try the same in a Scheduled task in Windows 

Sebastian_Linser_6-1664785891064.png

 

best regards

Sebastian

Help users find answers! Don't forget to mark a solution that worked for you! 🙂