Launching .bat problem

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
bidgeeman
Posts: 495
Joined: Wed Feb 21, 2007 7:58 am

Launching .bat problem

Post by bidgeeman » Thu May 21, 2009 3:03 am

Hello again.

I am having intermittent trouble with launching a .bat file from a standalone exe created in Runrev. It's strange as most time the bat file will launch but sometimes not correctly as it does not perform it's fnction and has to be double clicked via mouse to launch it properly. I am using this code:

on mouseUp
rename file "C:\data2.txt" to "C:\merge.bat"
set the hideConsoleWindows to true
launch "C:\merge.bat"
end mouseUp

Is there anything I am missing?

ny help would much appreciated please.
Bidge

Janschenkel
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 977
Joined: Sat Apr 08, 2006 7:47 am
Contact:

Post by Janschenkel » Thu May 21, 2009 7:12 am

While testing, you may want to set the hideConsoleWindows to false to see if this offers any clue about the failure. Does it make a difference if you replace the launch command with a call to the shell function?

Code: Select all

on mouseUp 
  rename file "C:\data2.txt" to "C:\merge.bat" 
  set the hideConsoleWindows to false  -- true 
  get shell("C:\merge.bat")
  if it is not empty then answer it
end mouseUp 
Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com

larryh
Posts: 32
Joined: Sat Mar 22, 2008 6:02 pm

Post by larryh » Thu May 21, 2009 7:15 am

Hi Bidge,

You might want to try using the shell function instead of launch and output the results to the msg box so that you can see what errors might be happening:

on mouseUp
rename file "C:\data2.txt" to "C:\merge.bat"
put "C:\merge.bat" into tBatchCommand
put shell(tBatchCommand) into msg
-- or use: get shell(tBatchCommand)
-- to run merge.bat without output to msg
end mouseUp

Larry

bidgeeman
Posts: 495
Joined: Wed Feb 21, 2007 7:58 am

Post by bidgeeman » Thu May 21, 2009 7:18 am

Thaks for the reply Janschenkel.
I'll give that a shot and see if it works any better. I don't know why it is'nt working sometimes but not others though? I'll let you know the results.

EDIT: oh...and thanks too larryh. Just missed your post as I replied to Janschenkel.

Many thanks
Bidge

bidgeeman
Posts: 495
Joined: Wed Feb 21, 2007 7:58 am

Post by bidgeeman » Thu May 21, 2009 9:21 am

Hi Janschenkel and larryh.

Thank you both for your suggestions and to Janschenkel for the code.

It works perfectly everytime!!! I would really like to know why the launch command does not work properly though. Maybe it is a bit buggy when it comes to .bat files?

Thank you both again very much.
Cheers
Bidge

bidgeeman
Posts: 495
Joined: Wed Feb 21, 2007 7:58 am

Post by bidgeeman » Fri May 22, 2009 1:54 am

Hi.
I'm having troubleexecuting the bat file fro windows shel. It worked fine when it was placed in the C: dirctory but now I want it to run from

C:\\Program Files\mp3tool

For some reson the shell is not executing the bat file? I've tried a number of combinations of backslashes but still won't work. Anyone know what i'm missing here?

Many thanks again.
Bidge

alemrantareq
Posts: 203
Joined: Wed Jul 23, 2008 8:46 am

Post by alemrantareq » Sat May 23, 2009 12:33 pm

Hi Bidge,

You may try it with "specialFolderPath" function. For example, you have a batch file named "Test.bat" which is located in "C:\Program Files\mp3tool" directory. Now you can apply the following code to run that batch file:

Code: Select all

on mouseUp
  put specialfolderpath(38) & "/mp3tool/Test.bat" into tfile
  launch document tfile
end mouseUp
I've tested this code with Revolution Studio 2.8.1 and it works prefect.

Here, "38" is the code of "Program Files" directory. To know more about "specialFolderPath" codes, click below:

http://www.sonsothunder.com/devres/revo ... ile010.htm

Hope it might be helpful.

bidgeeman
Posts: 495
Joined: Wed Feb 21, 2007 7:58 am

Post by bidgeeman » Sat May 23, 2009 12:39 pm

Wow...Thanks alemrantareq!

That is very helpfull.

Thank you!!!
Bidge

Post Reply