Batch file with a flag -- need assistance

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Thunder
Posts: 20
Joined: Thu Mar 12, 2015 1:52 pm

Re: Batch file with a flag -- need assistance

Post by Thunder » Tue Apr 16, 2019 2:02 am

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)

shawnblc
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 342
Joined: Fri Jun 01, 2012 11:11 pm
Location: USA

Re: Batch file with a flag -- need assistance

Post by shawnblc » Tue Apr 16, 2019 2:15 am

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.

shawnblc
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 342
Joined: Fri Jun 01, 2012 11:11 pm
Location: USA

Re: Batch file with a flag -- need assistance

Post by shawnblc » Tue Apr 16, 2019 2:57 am

Things like this keep me awake at night! lol.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9823
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Batch file with a flag -- need assistance

Post by FourthWorld » Tue Apr 16, 2019 3:04 am

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:

Code: Select all

 get shell(tfile)
 put it
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.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

shawnblc
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 342
Joined: Fri Jun 01, 2012 11:11 pm
Location: USA

Re: Batch file with a flag -- need assistance

Post by shawnblc » Tue Apr 16, 2019 3:28 am

@FourthWorld - When using that I get the expected output in the message box.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9823
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Batch file with a flag -- need assistance

Post by FourthWorld » 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?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

shawnblc
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 342
Joined: Fri Jun 01, 2012 11:11 pm
Location: USA

Re: Batch file with a flag -- need assistance

Post by shawnblc » 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.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9823
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Batch file with a flag -- need assistance

Post by FourthWorld » Tue Apr 16, 2019 3:43 am

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?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

shawnblc
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 342
Joined: Fri Jun 01, 2012 11:11 pm
Location: USA

Re: Batch file with a flag -- need assistance

Post by shawnblc » 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.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9823
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Batch file with a flag -- need assistance

Post by FourthWorld » 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?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

shawnblc
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 342
Joined: Fri Jun 01, 2012 11:11 pm
Location: USA

Re: Batch file with a flag -- need assistance

Post by shawnblc » Tue Apr 16, 2019 7:34 am

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.

SparkOut
Posts: 2852
Joined: Sun Sep 23, 2007 4:58 pm

Re: Batch file with a flag -- need assistance

Post by SparkOut » Tue Apr 16, 2019 7:44 am

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.

shawnblc
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 342
Joined: Fri Jun 01, 2012 11:11 pm
Location: USA

Re: Batch file with a flag -- need assistance

Post by shawnblc » Tue Apr 16, 2019 8:15 am

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.

SparkOut
Posts: 2852
Joined: Sun Sep 23, 2007 4:58 pm

Re: Batch file with a flag -- need assistance

Post by SparkOut » Tue Apr 16, 2019 10:07 am

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

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9823
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Batch file with a flag -- need assistance

Post by FourthWorld » Tue Apr 16, 2019 2:36 pm

Good tip, SparkOut.

What is the advantage to the user in displaying the output in the console window?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”