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
-
shawnblc
- VIP Livecode Opensource Backer
- Posts: 342
- Joined: Fri Jun 01, 2012 11:11 pm
- Location: USA
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: 5435
- Joined: Sat Feb 25, 2017 10:45 pm
Post
by bogs » Mon Apr 15, 2019 9:07 pm
Maybe shell out instead of launch would work.
-
shawnblc
- VIP Livecode Opensource Backer
- Posts: 342
- Joined: Fri Jun 01, 2012 11:11 pm
- Location: USA
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
- Posts: 9838
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
-
Contact:
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...?
-
shawnblc
- VIP Livecode Opensource Backer
- Posts: 342
- Joined: Fri Jun 01, 2012 11:11 pm
- Location: USA
Post
by shawnblc » Mon Apr 15, 2019 9:56 pm
The console window pops up and immediately closes.
-
FourthWorld
- VIP Livecode Opensource Backer
- Posts: 9838
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
-
Contact:
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?
-
shawnblc
- VIP Livecode Opensource Backer
- Posts: 342
- Joined: Fri Jun 01, 2012 11:11 pm
- Location: USA
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: 2852
- Joined: Sun Sep 23, 2007 4:58 pm
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
- Posts: 342
- Joined: Fri Jun 01, 2012 11:11 pm
- Location: USA
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: 2852
- Joined: Sun Sep 23, 2007 4:58 pm
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
- Posts: 342
- Joined: Fri Jun 01, 2012 11:11 pm
- Location: USA
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: 2852
- Joined: Sun Sep 23, 2007 4:58 pm
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
- Posts: 342
- Joined: Fri Jun 01, 2012 11:11 pm
- Location: USA
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 209 times
-
Thunder
- Posts: 20
- Joined: Thu Mar 12, 2015 1:52 pm
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
- Posts: 342
- Joined: Fri Jun 01, 2012 11:11 pm
- Location: USA
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.