dhruv_x0
19th October 2015, 17:58
Dear All,

I have a tool which is on my machine and there are several executable files to extract data from that tool. I created a batch file put it in my machine and i am successfully able to run batch file using this below command.
value = start.application.local (mdir & "test.bat",true,exitCode)

Now problem with this is that tool should be on each user's machine.

I thought to put that tool on server and then run all executable on server. I tried run.prog() but it doesn't work.

How can i solve this problem? Suggestions are welcomed.

Thanks

benito
19th October 2015, 21:22
i hate recommending a deprecated solution but have you tried the shell command? maybe someone else can suggest a better solution but this worked for me before. also the issue of having your little app in each user's machine is not really a big problem. you can create a little windows script attached to the user's logon profile. this script checks if the user has the app installed already and if not, then installs it.

JaapJD
20th October 2015, 09:28
shell() command does not work on Windows. run.prog() is the function you need to use to run batch file on the server. Maybe if you post your piece of code someone can see what's wrong...

bhushanchanda
20th October 2015, 13:29
Jaap is correct. Providing the code will help here. 2 most probable causes of failure -

1. Incorrect syntax/call
2. Not enough Privilege/permission on file

dhruv_x0
20th October 2015, 17:54
Not sure whats the problem here. I am getting "0" return value which means it is successful but i am not getting the desired results. Nothing in err.file also.
Here is the code:

value = run.prog("cmd.exe","/k"&"C:\"& "b1asharma1\test.bat",RP_WAIT,"","",err.file)

When i ran that batch file manually there it worked well. Here i am clueless now.

Thanks

bhushanchanda
20th October 2015, 18:07
I see there is no space between the 2 parameters.

Try this -

value = run.prog("cmd.exe","/k "&"C:\"& "b1asharma1\test.bat",RP_WAIT,"","",err.file)

Or you can even without cmd.exe

run.prog("C:\b1asharma1\test.bat","",RP_NOWAIT,"","","C:\b1asharma\err.txt")

Or

run.prog("C:\b1asharma1\test.bat","",RP_WAIT,"","","C:\b1asharma\err.txt")

I am assuming you have given full permission to this file and the folder.

dhruv_x0
21st October 2015, 14:26
Hi Bhushan,

Return field says "0" means successful but i stored error in file and i found one error there. Its says "'download_data' is not recognized as an internal or external command,operable program or batch file.".
Now when i ran that batch file manually it is executing without any error.
Content of batch file is "CD C:\XMDBTOOL\XMDBTool - HARSCO\bin
call download_data -downloadModule=ER -autoVerify=0"
This command is present in thiis path "CD C:\XMDBTOOL\XMDBTool - HARSCO\bin".

I am still trying on this. If you have any suggestions then please let me know.

Thanks

bhushanchanda
21st October 2015, 14:36
That's probably because, when you run it manually, the path stored in some environment variables is recognized as the program is called locally. But when called from LN/Baan, it becomes a remote program call and hence the command is not found.

Try one of this -

1. Set the path of the program in environment variable "PATH" on the server

or

2. Provide full path while using call statement instead of changing the directory.

or

3. Simply execute the program without creating the bat file using run.prog()

And off-course, make sure, the program can be ran by any user.

About the return statement -

The bat file is executed successfully and hence the return value is 0. If you run a program which returns any value for failed calls then probably you will get a different return value. But, in this case, run.prog() is executed properly but your bat file gives error which is stored in the log file.

run.prog() can fail if the bat file is not present or the name provided is incorrect and at those times you will get a different return value than 0,

Hope that helps.

Update -

You may also try this instead of CD

pushd yourdir

or

cd /D yourdir

e.g.

cd /D C:\XMDBTOOL\XMDBTool - HARSCO\bin
call download_data -downloadModule=ER -autoVerify=0

dhruv_x0
21st October 2015, 15:40
I set path on server "C:\XMDBTOOL\XMDBTool - HARSCO\bin" - nothing happened.

I tried to call without changing directory but i got the same message "It is not recognized as an internal or external command,operable program or batch file"

Also there is no such direct command for this. To run we need to write commands to CMD.

Thanks

bhushanchanda
21st October 2015, 15:48
There is one more thing you could try if possible.

I had faced a situation where the spaces in the path caused problems. Reason being that, the path may gets split and is converted into path and argument.

You can try to change the directory name and make it without spaces and check if that works.

Also, I had updated my previous answer. Try that as well.

dhruv_x0
21st October 2015, 16:13
I tried them all:confused:. No idea now why its not running that file.
Its not changing the directory because if it was able to change then it could have run easily. Its trying to run the call command that's why "recognized error" is coming. I will keep looking into this and will post if i could find anything.

Thanks

bhushanchanda
21st October 2015, 16:25
For testing purpose, what you can do is, try creating 2 bat files. Now, call 2nd from 1st bat file. Now, use run.prog() to call 1st bat file. It will give you a hint whether there is a problem.

Also, if you have simply added the path to that program and not the full path with the program name in "Path" environment variable, I will suggest you to add the full path as well and try again.


Once you add the full path, open you command prompt and type that program name and hit enter to see if its able to run directly.

It takes quite brainstorming dealing with some issues. Hope you get it working. All the best!

bhushanchanda
21st October 2015, 16:27
And do check this link (http://stackoverflow.com/questions/13994250/how-do-i-launch-multiple-batch-files-from-one-batch-file-with-dependency)

benito
21st October 2015, 16:39
from your local pc, hit Start and can you try typing \\name-of-your-server\C$\XMDBTOOL\blah-blah. Can you access your folder and your executable through this?

go to dos command and try accessing the remote server directory. type dir /x. it will display the long and shortnames. i am thinking that maybe try using the shortnames like DOCUME~1 instead of long names.

see a sample file:

C:\Windows\startm~1\programs\startup\somefile.doc

baanspider
26th November 2020, 16:58
Hi support

When running the bat file in Windows, there is no issue

But when I call the bat file with run.prog, one of the commands do not run

The command is
java.exe CreateSMime

This command encrypts one txt file to p7m file

Please advise

thanks

bhushanchanda
26th November 2020, 17:32
Try using full path of your Java installation and the java program in run.prog()

Also try using

run.prog("cmd", "/c " & path_to_java & " " & path_to_program,RP_WAIT,"","")

avpatil
4th December 2020, 17:28
For running java file through run.prog one may have to give path for java class. I had done many interfsaces in past using Java program through run program. One of them was to process credit card transaction in Baan IV on real time

dunvince
14th April 2021, 23:09
I used the following to get my batch file to run from my Windows server.
The batch file runs fine and runs as the logged in user. Any user that needs to do this will need file permissions set.

execfile = "D:\testfolder\Upload.bat"
ret = run.prog("cmd.exe", "cmd /c " & execfile , RP_WAIT, ifile, ofile, errfile)