Page 2 of 3
Re: Batch file with a flag -- need assistance
Posted: Tue Apr 16, 2019 2:02 am
by Thunder
shawnblc wrote: Tue Apr 16, 2019 1:44 am
Yes. Even if the app is compiled and the exe is run as administrator the same thing happens (console flashes). You can also do runas Administrator in lc scripting. The bat file just can't be run from the Program Files directory.
In your mouseUp handler, try to add :
Code: Select all
put quote & tfile & quote into tfile
get shell(tfile)
Edit:
You should also change all "/" with "\" in tfile before get shell(tfile)
so it should look something like this :
Code: Select all
--launch document tfile
put quote & tfile & quote into tfile
replace "/" with "\" in tfile
get shell(tfile)
Re: Batch file with a flag -- need assistance
Posted: Tue Apr 16, 2019 2:15 am
by shawnblc
Same thing ... the console flashes, even when compiled into an exe and run as administrator.
Let me try that second part and update .
Update: same thing, the console flashes.
Re: Batch file with a flag -- need assistance
Posted: Tue Apr 16, 2019 2:57 am
by shawnblc
Things like this keep me awake at night! lol.
Re: Batch file with a flag -- need assistance
Posted: Tue Apr 16, 2019 3:04 am
by FourthWorld
1. The console window is normal. You've commented out the part that prevents that from happening.
2. Use shell rather than launch for this. Really. SparkOut has no reason to mislead you on that. It's what you want.
3. You can't really know what's happening because you're not checking the return value. Add this after the shell call add a line to display what comes back from that function, a la:
4. When you see the error it's trying to tell you, note how you're building the file path. Remember that within LC all paths use Unix conventions, so to pass something to Windows you'll want to replace "/" with "\" in part that uses the stack's file name.
5. Once the path is normalized, run it again and see what the return value is. In short, the script appears to be called just fine, but paths referenced within the batch file are throwing errors.
Re: Batch file with a flag -- need assistance
Posted: Tue Apr 16, 2019 3:28 am
by shawnblc
@FourthWorld - When using that I get the expected output in the message box.
Re: Batch file with a flag -- need assistance
Posted: Tue Apr 16, 2019 3:32 am
by FourthWorld
shawnblc wrote: Tue Apr 16, 2019 3:28 am
@FourthWorld - When using that I get the expected output in the message box.
Does that mean the issue is resolved?
Re: Batch file with a flag -- need assistance
Posted: Tue Apr 16, 2019 3:33 am
by shawnblc
FourthWorld wrote: Tue Apr 16, 2019 3:32 am
shawnblc wrote: Tue Apr 16, 2019 3:28 am
@FourthWorld - When using that I get the expected output in the message box.
Does that mean the issue is resolved?
Negative, it's not going to the console.
Re: Batch file with a flag -- need assistance
Posted: Tue Apr 16, 2019 3:43 am
by FourthWorld
shawnblc wrote: Tue Apr 16, 2019 3:33 am
FourthWorld wrote: Tue Apr 16, 2019 3:32 am
shawnblc wrote: Tue Apr 16, 2019 3:28 am
@FourthWorld - When using that I get the expected output in the message box.
Does that mean the issue is resolved?
Negative, it's not going to the console.
It should be returned to your LC script rather than the console. That's what I see here. Are you getting no return value?
Re: Batch file with a flag -- need assistance
Posted: Tue Apr 16, 2019 3:49 am
by shawnblc
The message box has the correct output in it (from the bat file), as expected. The console flashes and disappears.
Re: Batch file with a flag -- need assistance
Posted: Tue Apr 16, 2019 4:23 am
by FourthWorld
shawnblc wrote: Tue Apr 16, 2019 3:49 am
The message box has the correct output in it (from the bat file), as expected. The console flashes and disappears.
As noted earlier, uncommenting the line "set the hideConsoleWindows to true" fixed that for me. If that isn't working for you we may need to file a bug report.
So aside from that cosmetic detail, the rest is working?
Re: Batch file with a flag -- need assistance
Posted: Tue Apr 16, 2019 7:34 am
by shawnblc
FourthWorld wrote: Tue Apr 16, 2019 4:23 am
shawnblc wrote: Tue Apr 16, 2019 3:49 am
The message box has the correct output in it (from the bat file), as expected. The console flashes and disappears.
As noted earlier, uncommenting the line "set the hideConsoleWindows to true" fixed that for me. If that isn't working for you we may need to file a bug report.
So aside from that cosmetic detail, the rest is working?
If you "set the hideConsoleWindows to true" then the console window is hidden and the -h flag does nothing. The whole purpose of the -h flag is to get help in the console window.
I'll file a bug report.
Re: Batch file with a flag -- need assistance
Posted: Tue Apr 16, 2019 7:44 am
by SparkOut
Ah, wait... this isn't a bug, I don't think.
You want to open the command prompt to run the bat file in the command console and remain open on screen with the batch file results showing? Rather than have the results passed back to LiveCode for display/processing?
So your shell command should not just contain the path to the batch file, but you should make the "command" (cmd) the statement with the path to the batch file as an argument. This will need careful handling of the quotes wrapping everything up.
Re: Batch file with a flag -- need assistance
Posted: Tue Apr 16, 2019 8:15 am
by shawnblc
Correct. The command prompt console should remain open. Just as if you were running the bat file from the command line. Nothing is passed back to LC.
Re: Batch file with a flag -- need assistance
Posted: Tue Apr 16, 2019 10:07 am
by SparkOut
Ok.
Try
Code: Select all
put "cmd /k" && tFile into tFile
get shell (tFile)
put it
Or add "cmd /k" as the last line of your batch file
Re: Batch file with a flag -- need assistance
Posted: Tue Apr 16, 2019 2:36 pm
by FourthWorld
Good tip, SparkOut.
What is the advantage to the user in displaying the output in the console window?