fmorais
10th October 2002, 01:08
Hi,
Trying to use run.prog() to copy and delete files on an NT server:
id=run.prog("copy c:\file1 c:\file2","",RP_WAIT)
It does not work. The return value (id) is 1.
The same happens if I try to use a batch file to do the same.(id=run.prog("xxx.bat","",RP_WAIT).
However, the function seems to work if the command is notepad, excel, etc...only does not work for DOS commands.
Any suggestions?
Thanks a lot
FRED
~Vamsi
10th October 2002, 01:22
You will have to start a command shell before you can execute those commands. Try:
id=run.prog("cmd /c", "copy c:\file1 c:\file2", RP_WAIT)
While the above should work, it is strongly urged that you use standard Baan file related functions. You can get a look at what is available http://www.baanboard.com/programmers_manual_baanerp_help_functions_directory_file_operations_synopsis
fmorais
10th October 2002, 03:08
Thanks for the tip, and the prompt answer.
Tried it. Does not work.
However, if I create a *.bat with the commands and call it from run.prog(), it works.
Can it be because I'm using BIVc4?
Will try to use the dllfilehand commands instead for these kind of operations on the server.
Thanks
Fred
trchandra
10th October 2002, 07:25
Fred,
You need to keep the '/c' in second argument as shown below...
id=run.prog("cmd.exe", "/c copy c:\file1 c:\file2", RP_WAIT)
fmorais
10th October 2002, 19:05
Ravi,
That was indeed the problem. Everything is working now.
Thanks Ravi and Vamsi.
Fred
Han Brinkman
10th October 2002, 21:44
If you want to write portable software you should use the file functions like file.mv
Rgrds,
Han
Embrau
11th October 2002, 17:22
Fred
Probably it's better to use this command (id=run.prog("copy c:\file1 c:\file2","",RP_WAIT)) with the option 'RP_NOWAIT'.
Windows can not return the result of executing the command you specified, so you have to negotiate the returnvalue of the action you did in the command.
My example:
a= run.prog("COMMAND.COM","/C type :\vd_dump\vglfile\vgl_file.txt > lpt1" , RP_NOWAIT)
Regards.
Nad2006
18th December 2006, 20:36
Hello,
I am working on Baan4_c4 and windows 2000 and I am trying this but it's not working:
e = run.prog("command.com", "/c copy e:\My_info.doc e:\copy.doc", RP_WAIT)
e = 0 but no copy is done.
Please advice.
Thanks
fmorais
18th December 2006, 20:46
Hi.
I am not sure that "command.com" works the same as "cmd.exe". My example is working with "cmd.exe".
Anyway, I had problems running this command because of user permissions.
The symptom was the same as you describe. Everything seemed to run ok, return code ok, but the file was not copied.
Are you sure that the user that is running the baan session has permissions for the relevant directories?
Regards
Fred
Nad2006
18th December 2006, 21:32
Hi fred,
Actually, I tried both "Command.com" and "cmd.exe" but none of them work.
I am executing this through a job (running on the server) so it's Baan user permissions that cause this. I am presently trying to use the file.chown() before file.cp(); but I am not sure it'll make a change.
Thank you for your suggestions.
Nad
george7a
19th December 2006, 09:05
Hi,
Check if you have write permissions on that directory.
Also check this thread:
http://www.baanboard.com/baanboard/showthread.php?t=1597
I hope it helps,
- George
Anshu_Jain
15th May 2008, 13:30
The "/c" was indeed critical.
It worked well on BaanIVc4 - Windows 2003 server
cheers
Anshu
Fred,
You need to keep the '/c' in second argument as shown below...
id=run.prog("cmd.exe", "/c copy c:\file1 c:\file2", RP_WAIT)