Page 1 of 3

Batch file with a flag -- need assistance

Posted: Mon Apr 15, 2019 8:09 pm
by shawnblc
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

Re: Batch file with a flag -- need assistance

Posted: Mon Apr 15, 2019 9:07 pm
by bogs
Maybe shell out instead of launch would work.

Re: Batch file with a flag -- need assistance

Posted: Mon Apr 15, 2019 9:30 pm
by shawnblc
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)
   

Re: Batch file with a flag -- need assistance

Posted: Mon Apr 15, 2019 9:54 pm
by FourthWorld
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...?

Re: Batch file with a flag -- need assistance

Posted: Mon Apr 15, 2019 9:56 pm
by shawnblc
The console window pops up and immediately closes.

Re: Batch file with a flag -- need assistance

Posted: Mon Apr 15, 2019 11:06 pm
by FourthWorld
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?

Re: Batch file with a flag -- need assistance

Posted: Mon Apr 15, 2019 11:20 pm
by shawnblc
No the target program did not do what I want. No error was reported.

Re: Batch file with a flag -- need assistance

Posted: Mon Apr 15, 2019 11:42 pm
by SparkOut
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)

Re: Batch file with a flag -- need assistance

Posted: Mon Apr 15, 2019 11:49 pm
by shawnblc
@SparkOut when I put answer tfile I get the appropriate response. I'll experiment with quotes.

Re: Batch file with a flag -- need assistance

Posted: Mon Apr 15, 2019 11:55 pm
by SparkOut
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.

Re: Batch file with a flag -- need assistance

Posted: Tue Apr 16, 2019 12:16 am
by shawnblc
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.

Re: Batch file with a flag -- need assistance

Posted: Tue Apr 16, 2019 12:24 am
by SparkOut
So, what do you get with

Code: Select all

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

Re: Batch file with a flag -- need assistance

Posted: Tue Apr 16, 2019 12:47 am
by shawnblc
@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.

Re: Batch file with a flag -- need assistance

Posted: Tue Apr 16, 2019 1:41 am
by Thunder
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 ?

Re: Batch file with a flag -- need assistance

Posted: Tue Apr 16, 2019 1:44 am
by shawnblc
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.