I am trying to run a .bat file (SendXML) which takes one argument
If I do it from cmd prompt I just type
So I thought I would try with this code, in Xojo
But it did not work, complaining that the system can’t find the XML file
To check which argument was passed to the .bat file I inserted echo %1 in the bat file… and here’s the shell.result (obviosly SendXML did NOT send the XML )
What is the character before the file path ? Is that the problem ?
Without looking at the bat code, difficult to know what is going on. But shell does not work quite as does the command prompt.
At first glance, though, your code seems ill formed. Those extra quotes and the comma are not necessary IMHO. I would simply do :
dim sh as new shell
Of course, PathToTheFolder must be the valid path to your SendXml.bat file, and cierrez.xml must be at the root of e:.
What if you just do this?
sh.Execute(chr(34)+"F:\\PathToTheFolder\\Sendxml.bat"+chr(34) + " E:\\cierrez.xml")
BTW, you can double-up quotes to insert them into a string, so this might be easier in the future:
here’s the bat code
if “%1” == “” goto salgo
curl --noproxy 127.0.1.1 http://127.0.1.19/fiscal.xml -H “Content-Type: text/xml” -ss -m 3 --data-binary @%1 > resp.xml
echo . ERROR de invocaci¢n… !! - Falta indicar archivo XML.
echo . Ejemplo: sendxml archivo.xml
echo . ### FIN ###
Hey Kem… I get the same results trying with your suggestion…
I still get that funny character (like a pike or spade) before the path…
Michel… is it not E:\cierrez.xml a parameter ?
Shell.Execute(Command as String [,Parameters as String])
Basically, Shell takes the very same syntax as the command prompt. You do not need to separate the parameters with a comma.
But from what I see in your picture, you get an access denied to CierreZ.xml (note there are uppercase there). That is the error.
You have to know that shell cannot elevate privileges. So what you can do as a logged user to access a file on e: may not be available to your app.
You may try instead to launch the bat with parameters.
Dim f as folderItem = GetFolderItem("F:\\PathToTheFolder\\Sendxml.bat", FolderItem.PethTypeShell)
Michel, thanks for your help… I can’t understand why, but still it is not working…
It’s still complaining that system CANT FIND THE FILE… Isn’t the ? character preceeding the path revealing something ? Is it supposed to be there ?
Alright… So I finaaallly… got to the issue…
The problem was within the .bat file… it points to two files… curl(.exe) and resp.xml, which is where the output of curl was supposed to be placed…
As i run the bat from command line I was in the folder containing curl, and the resp.xml but when I run the .bat file from a Xojo shell the inital path was Xojo/whatever/debug/myapp/whatever… therefore the errors… If i set the absolute path of curl and resp.xml in the BAT file… it seems to work ok now.
Thanks for helping out.
By the way… How can I start a shell in a certain directory other than the running app folder ?
Already asked by myself and already answered by Michael
time to have some rest…
You can’t. That’s basic shell programming 101. Always specify full path names or use system path variables. Never assume anything about where the shell runs. This is true of any batch file programming. It’s not specific to Xojo.