-1

I was making a program and then exported the code to a .jar file. To make my program work I needed a .bat file. Now I want to fuse the .bat and .jar to an exe where the .bat file will run and the .jar will not. Thank.

Here is my .bat file:

@echo off
title Test Coding Language
echo Welcome to TCL
pause 
java -jar TestCodingLanguage.jar
Compo
  • 36,585
  • 5
  • 27
  • 39
Uncodeable864
  • 25
  • 1
  • 5
  • 1
    Please read [ask], especially [How do I ask a good question?](https://stackoverflow.com/help/how-to-ask), [What topics can I ask about here?](https://stackoverflow.com/help/on-topic) and [What types of questions should I avoid asking?](https://stackoverflow.com/help/dont-ask). Once you've done that, please consider deleting the above, and posing it on [Super User](https://superuser.com/questions/ask) instead or [edit](https://stackoverflow.com/posts/59013787/edit) your question to follow the advice based upon what you've learned from the links. – Compo Nov 24 '19 at 01:48
  • If you edit your question and show us the contents of your .bat file, we might be able to suggest a way to avoid using a .bat file entirely. – VGR Nov 24 '19 at 02:34
  • Check this - https://stackoverflow.com/questions/28174386/how-can-a-bat-file-be-converted-to-exe-without-third-party-tools . You can use this as base to pack the bat and the jar together and call the bat file. – npocmaka Nov 24 '19 at 08:19
  • Did you want a .COM file to run the .EXE file as wel? Where is this going to end? – user207421 Nov 24 '19 at 09:46

1 Answers1

1

Try the code bellow by saving it in a bat file. It will pack a bat file and jar in an executable and will call the bat file. You'll have to change the paths to your files:

;@echo off

;rem ----------------------------------------------------------
;rem ----------------- change the paths here -----------------
;rem ----------------------------------------------------------
;set "target_exe=packed.exe"
;set "bat_file=.\test.bat"
;set "jar_file=.\cassandra-jdbc-driver-0.6.4-shaded.jar"
;rem ----------------------------------------------------------

;for %%# in ("%bat_file%") do set "batch_file=%%~nx#"
;for %%# in ("%bat_file%") do set "bat_name=%%~nx#"
;for %%# in ("%bat_file%") do set "bat_dir=%%~dp#"

;for %%# in ("%jar_file%") do set "j_file=%%~nx#"
;for %%# in ("%jar_file%") do set "jar_name=%%~nx#"
;for %%# in ("%jar_file%") do set "jar_dir=%%~dp#"


;set "target.exe=%__cd__%%target_exe%"


;copy /y "%~f0" "%temp%\2exe.sed" >nul

;(echo()>>"%temp%\2exe.sed"
;(echo(AppLaunched=cmd.exe /c "%bat_name%")>>"%temp%\2exe.sed"
;(echo(TargetName=%target.exe%)>>"%temp%\2exe.sed"
;(echo(FILE0="%bat_name%")>>"%temp%\2exe.sed"
;(echo(FILE1="%jar_name%")>>"%temp%\2exe.sed"

;(echo([SourceFiles])>>"%temp%\2exe.sed"
;(echo(SourceFiles0=%bat_dir%)>>"%temp%\2exe.sed"
;(echo(SourceFiles1=%jar_dir%)>>"%temp%\2exe.sed"

;(echo([SourceFiles0])>>"%temp%\2exe.sed"
;(echo(%%FILE0%%=)>>"%temp%\2exe.sed"

;(echo([SourceFiles1])>>"%temp%\2exe.sed"
;(echo(%%FILE1%%=)>>"%temp%\2exe.sed"


;iexpress /n /q /m %temp%\2exe.sed

;rem del /q /f "%temp%\2exe.sed"
; exit /b 0

[Version]
Class=IEXPRESS
SEDVersion=3
[Options]
PackagePurpose=InstallApp
ShowInstallProgramWindow=0
HideExtractAnimation=1
UseLongFileName=1
InsideCompressed=0
CAB_FixedSize=0
CAB_ResvCodeSigning=0
RebootMode=N
InstallPrompt=%InstallPrompt%
DisplayLicense=%DisplayLicense%
FinishMessage=%FinishMessage%
TargetName=%TargetName%
FriendlyName=%FriendlyName%
AppLaunched=%AppLaunched%
PostInstallCmd=%PostInstallCmd%
AdminQuietInstCmd=%AdminQuietInstCmd%
UserQuietInstCmd=%UserQuietInstCmd%
SourceFiles=SourceFiles

[Strings]
InstallPrompt=
DisplayLicense=
FinishMessage=
FriendlyName=-
PostInstallCmd=<None>
AdminQuietInstCmd=
UserQuietInstCmd=
;
npocmaka
  • 55,367
  • 18
  • 148
  • 187