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: Klaus, FourthWorld, heatherlaine, kevinmiller

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

Batch file with a flag -- need assistance

Post by shawnblc » Mon Apr 15, 2019 8:09 pm

How can I get my batch file to run with a flag?


This doesn't work.

Code: Select all

  set the itemDelimiter to "/"
   put (item 1 to -2 of the effective fileName of this stack) & "\scripts\runme\runme.bat -h" into tfile
   launch document tfile
This does work, but doesn't contain the flag.

Code: Select all

  set the itemDelimiter to "/"
   put (item 1 to -2 of the effective fileName of this stack) & "\scripts\runme\runme.bat" into tfile
   launch document tfile

bogs
Posts: 3100
Joined: Sat Feb 25, 2017 10:45 pm

Re: Batch file with a flag -- need assistance

Post by bogs » Mon Apr 15, 2019 9:07 pm

Maybe shell out instead of launch would work.
Image

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

Re: Batch file with a flag -- need assistance

Post by shawnblc » Mon Apr 15, 2019 9:30 pm

This didn't work either.

Code: Select all

  set the itemDelimiter to "/"
   put (item 1 to -2 of the effective fileName of this stack) & "\scripts\runme\runme.bat -h" into tfile
   -- launch document tfile
   get shel(tfile)
   

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

Re: Batch file with a flag -- need assistance

Post by FourthWorld » Mon Apr 15, 2019 9:54 pm

shawnblc wrote:
Mon Apr 15, 2019 9:30 pm
This didn't work either.

Code: Select all

  set the itemDelimiter to "/"
   put (item 1 to -2 of the effective fileName of this stack) & "\scripts\runme\runme.bat -h" into tfile
   -- launch document tfile
   get shel(tfile)
   
"Didn't work" measn no action happened at all, or an action happened but the result was unexpected, or it threw an error, or...?
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

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

Re: Batch file with a flag -- need assistance

Post by shawnblc » Mon Apr 15, 2019 9:56 pm

The console window pops up and immediately closes.

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

Re: Batch file with a flag -- need assistance

Post by FourthWorld » Mon Apr 15, 2019 11:06 pm

shawnblc wrote:
Mon Apr 15, 2019 9:56 pm
The console window pops up and immediately closes.
That's expected on Windows. It may even be a sign of success. You can control that with the hideConsoleWindows global property.

The key is: did the target program run? Did it do what you were expecting? If not, did it return an error to your calling script?
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

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

Re: Batch file with a flag -- need assistance

Post by shawnblc » Mon Apr 15, 2019 11:20 pm

No the target program did not do what I want. No error was reported.

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

Re: Batch file with a flag -- need assistance

Post by SparkOut » Mon Apr 15, 2019 11:42 pm

You may need to experiment with the quotes wrapping the path you provide.
1, what do you get if you answer tfile immediately before the shell command.
2, on Windows you could need a dummy pair of double quotes before the tfile path to act as an empty title for the console window (put quote & quote & space before tfile - but again the whole wrapping in correct pairs of quotes could be an issue)

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

Re: Batch file with a flag -- need assistance

Post by shawnblc » Mon Apr 15, 2019 11:49 pm

@SparkOut when I put answer tfile I get the appropriate response. I'll experiment with quotes.

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

Re: Batch file with a flag -- need assistance

Post by SparkOut » Mon Apr 15, 2019 11:55 pm

What is the appropriate response? By which I mean, if you copy and paste *exactly* that into a command prompt, what happens?
If it works, then a dummy console title of a pair of double quotes beforehand might be the answer. If not, your whole variable and / or quote wrapping is an issue.

shawnblc
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 331
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 12:16 am

SparkOut wrote:
Mon Apr 15, 2019 11:55 pm
What is the appropriate response? By which I mean, if you copy and paste *exactly* that into a command prompt, what happens?
If it works, then a dummy console title of a pair of double quotes beforehand might be the answer. If not, your whole variable and / or quote wrapping is an issue.
If copy and pasted exactly into a command prompt I get the help menu that I expect to.

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

Re: Batch file with a flag -- need assistance

Post by SparkOut » Tue Apr 16, 2019 12:24 am

So, what do you get with

Code: Select all

put quote & quote && tFile into tFile
get shell(tFile)
answer it

shawnblc
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 331
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 12:47 am

@SparkOut the above didn't work either, same thing ... the console popped up and disappeared. This has me stopped in my tracks.

I have a test file attached.
Attachments
test.7z
(64.16 KiB) Downloaded 6 times

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

Re: Batch file with a flag -- need assistance

Post by Thunder » Tue Apr 16, 2019 1:41 am

shawnblc wrote:
Tue Apr 16, 2019 12:47 am
@SparkOut the above didn't work either, same thing ... the console popped up and disappeared. This has me stopped in my tracks.

I have a test file attached.

Hi

in your tron.bat file :

:: Requirements: Run from the current users desktop. Run as Administrator.

do you run the bat file as Administrator ?

shawnblc
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 331
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 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.

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”