Link to home
Start Free TrialLog in
Avatar of TLTEO
TLTEO

asked on

using batlite

Hi  

Is it possible to change a .com file to .exe  and they function the smae way still?


I am using a batlite to convert a batch file which calls for Java classes.

When I manage to cinvert it, I change the extension to .exe from .com.


and in the registry, I set the shell command as

"c:\program files\myprog\myprog.exe""%1"


This doe not seems to work at all.  


even if I doubke click on this file myprog.exe, it says
shell cannot run batlite.

What is the probable problem /?
Avatar of griessh
griessh
Flag of United States of America image

The extension .com and .exe tells your OS how to start the application. .com files are made for a more compact memory model and have a different way to get started. DON'T change the extension. There are program that do the exe2com for you, but not every program can be converted!

======
Werner
I think all Windows version still have the old exe2bin utility included that will do that job for you.

======
Werner
Avatar of rin1010
rin1010


TLTEO,

You can rename an executable with a .com extension and it will run,
but as Werner notes you'll usually have problems doing it the other way.

But I've created .com files using BatLite and renamed the created file's
.com extension to .exe and they run without a problem...
So your difficulty could be a syntax error elsewhere
or possibly a command in the batch script that BatLite doesn't understand.
Its documentation may mention something about it,
but post back with the exact error message if it's still doing it...
 

btw... i have a copy of the EXE2BIN utility that Werner mentions
and will place it where you can get it or provide an url if needed,
but it's for converting .exe (executable) files to binary format...
 

Avatar of dbrunton
Your program must also be smaller than 64 Kb as well for the conversion to work.  This means that all data, stack, and code in the exe file must fit inside 64 Kb on conversion.  If it doesn't then it will not work as a com file.  How big are the files you are trying to convert?
Avatar of TLTEO

ASKER

I am trying to use a .com file to run a java program.

I wonder if I convert this .bat to .com,  can I change the registry shell command as

"C:\program files\myprog\myprog.com" "%1"


My java program is stored in a jar file (200K)  and batch file goes like this

set path="c:\Program Files\Javasoft\JRE\1.3.1\bin";"c:\windows\command"
java -cp myporg.jar mrprog %1
cls
exit


it was converted to a .com file


when i try to click on the myprog.com, it says

shell cannot run Batlite

>> shell cannot run Batlite
That seems more like your program is missing a  path to the BatLite executable ... Somebody please help out: does the binary still need Batlite?

======
Werner

No, the created com file is stand-alone and no longer requires BatLite...
Also, executables larger that 64K can be given a .com extension
and still run... It can be tested on executables >64K such as
explorer.exe, scandisk.exe, cdplayer.exe, etc...

The error message being generated is internal to the .com created by BatLite...
The message "Shell can't run BatLite" is written to the compiled command...
The "Shell" referred to in this case could be a new instance of the command interpreter
and calling the BatLite com using Java's -classpath alias option isn't allowing it
to return to the compiled batch file after calling the other program.

If it works ok as a regular batch file, then you may get it to work
using BatLite's /nobatch switch, which tells the compiled script to continue,
or else use the Call command in the batch script before compiling.

If this is related to your lfn problem, then that could also confuse BatLite
and generate the error message. If you first get the batch file working as you want,
you can then try to isolate the specific bug causing the BatLite error
or try to compile it using another utility such as Bat2Exec or TurboBat, etc...

Another thing about changing a BatLite compiled .com extension to .exe
under Windows 9.x is that Windows may try to run the command as a 32-bit app...
For example; create a batch file having a simple command, such as:    dir
Save it with a name like test.bat and compile it with BatLite,
then rename the created test.com to test.exe ...
Now open a dos box and run test.exe and you should see a directory listing
as per the test.bat script. But the way it's compiled, you'll probably get an error
when attempting to run it from File Manager, Program Manager, Explorer
or similar Windows shell. So once you get it working as needed,
you may need another method to make it a command if still necessary,
especially if you're getting the error regardless of extension.
 
Avatar of TLTEO

ASKER

My basic idea is to remove the ugly DOS screen after I have started the Java program.

In win98/ME,  I can remove it by adding a exit in the end of the batch file.And enable the 'close on exit' function.   By I can't do it in win2000 n NT, cos there is no such function.

I have been searching for an answer for a while. Do you know how to do it??

@echo off
cls

does not work automatically

How to close all DOS screen after java program starts?? Is it that only .exe can do it??


It's strange that the dos box won't close, unless your app is still running...
And no, it's not that only an executable can do it, even with data left on the screen.
I thought the default for NT/2K was for the window to close upon completion...
In 9.x (as you note) you can enable the "close on exit" option
or use cls at the end of a batch file to close a dos box...
Under 2K it should close after the program finishes,
like using the command.com /c switch...

The NT/2K command interpreter (comspec) is cmd.exe and you can try using it
to call your script or program. You'll have a copy of command.com too
and can test it to start and close or emulate a virtual dos box...
Or just run cmd.exe /k and see if the window shuts...
If so, use the Console program in Control Panel
and check the properties for your specific app...

You might try (in your script) changing to the root
and using the Exit command, like:

cd\
exit
cls

Also explore the recovery console for os environment settings
and try using Start.exe to launch the program using one of its options...
Type Start/? at a prompt for its switches.

That's all i can think of for now and i'm not on a machine having that os
to test it, but maybe I can think of something tomorrow if you don't get it by then
or someone else knows what the deal is. You have so much going there
with java running your app and a batch file being passed a parameter
(compiled as a command with the extension changed to .exe?)
that it's hard to emulate what you're doing there to debug it...
But if you don't get it working like you want, post back
with details of what you have at this point
and we'll try to make it work...
 
Avatar of TLTEO

ASKER

OK  my batch file goes like this  in NT

cd\ start cmd.exe
javaw -cp myprog.jar myMain %1
cls
exit


It does not close at all.


by right javaw    wud run w/o showing any outputs, and cls shd clear the screen and box.


It works in 98   but just soem how dont in 2000/NT (no 'close on exit' properties found).




TLTEO

By starting the batch file you have a DOS shell already! Since you start another cmd.exe, you have two of them and it won't close the extra one ... just remove the
"start cmd.exe"
line.
======
Werner

TLTEO,

There's no need to use cmd.exe in that manner... I'd meant to use it preceding your app
with the /c switch to execute your program and then return as a test to close the window...
The idea to cd\ to the root and then using exit was just a suggested workaround to try,
separate from the comspec thing...

But you should be able to create or edit a PIF for your batch file and have options like
'close on exit'... On the NT or 2K machine you're using, right click your batch file
in Explorer and choose 'Properties'... The PIF Editor's Program tab
should allow you to enable 'close on exit' and 'run minimized,' etc...

Also look under the Screen and Misc and other tabs for items that might help
when running it under NT/2K... You might try disabling the 'Windows NT'
and 'Compatible Timer Hardware' and 'Idle Detection' options...
(These have nothing to do with closing the dos box but may improve performance.)

So check that out and see if it gets you anywhere...
Also maybe just try your batch file different ways
using Pause to halt processing and perhaps
indicate where it's failing to close, like:

javaw -cp myprog.jar myMain %1
pause
cls

...and:

javaw -cp myprog.jar myMain %1
pause
exit

...and:

javaw -cp myprog.jar myMain %1
cls
pause
exit

And if you test using Start.exe use it to launch your batch file or app, like:

Start [option] javaw -cp myprog.jar myMain %1

 
Avatar of TLTEO

ASKER

Hi


there isnt any 'close on exit' in NT/2k.  I can get .pif file into them ,  all I can get is a.lnk  file .. in which there is no such function.  Where can I find it ??

As a matter of fact,  I dont need .pif file now (they are just short cuts). But  I do need to create a short cut to batch files.

Batch files in NT/2k   does not have 'close on exit'  functions.  How come I cudn't find them ??


ASKER CERTIFIED SOLUTION
Avatar of rin1010
rin1010

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
TLTEO:

You have many open questions:

https://www.experts-exchange.com/jsp/qShow.jsp?qid=20077765
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20177485
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20178630
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20177653
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20235670
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20177859
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20250974
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20148640

To assist you in your cleanup, I'm providing the following guidelines:

1.  Stay active in your questions and provide feedback whenever possible. Likewise, when feedback has not been provided by the experts, commenting again makes them receive an email notification, and they may provide you with further information. Experts have no other method of searching for questions in which they have commented, except manually.

2.  Award points by hitting the Accept Comment As Answer button located above and to the left of that expert's comment.

3.  When grading, be sure to read:
https://www.experts-exchange.com/jsp/cmtyQuestAnswer.jsp#3
to ensure that you understand the grading system here at EE. If you grade less than an A, you must explain why.

4.  Questions that were not helpful to you should be PAQ'd (stored in the database for their valuable content?even if not valuable to you) or deleted. To PAQ or delete a question, you must first post your intent in that question to make the experts aware. Then, if no experts object after three full days, you can post a zero-point question at community support to request deletion or PAQ. Please include the link(s) to the question(s).
CS:  https://www.experts-exchange.com/jsp/qList.jsp?ta=commspt
At that point, a moderator can refund your points and PAQ or delete the question for you. The delete button does not work.

5.  If you fail to respond to this cleanup request, I must report you to the Community Support Administrator for further action.

Our intent is to get the questions cleaned up, and not to embarrass or shame anyone. If you have any questions or need further assistance at all, feel free to ask me in this question or post a zero-point question at CS. We are very happy to help you in this task!


thanks!
amp
community support moderator

2/4