Why does a program started by a batch file using command start not run while it runs via Windows Explorer? - windows

::Checks if there is a JRE installed
start "%USERPROFILE%\Downloads\ConfCompiler\Tools\CheckJre.exe"
When I copy and paste the file location above into Windows Explorer it works fine. But the program does not run from the batch file I have created.
The purpose of CheckJre.exe is to create new keys inside of HKEY_CURRENT_USER.
The keys are created when I simply run it from Windows Explorer. But the keys are NOT created when running it from the batch file. The batch file just results in displaying a command prompt window with showing CheckJre.exe with full path in title bar.
Does anyone have a hint why?

Command start interprets the first double quoted string as title for the command line window to open. For all options of command start enter in a command prompt window either start /? or help start.
You need to explicitly specify a title in your batch file because of the double quoted string to run CheckJre.exe.
Use in batch file:
start "Check JRE" "%USERPROFILE%\Downloads\ConfCompiler\Tools\CheckJre.exe"

Related

Can't open a .chm file from a batch file

I am trying to open a .chm file from a batch file.
The batch file has only this text in it :
echo off
start "S:\G.T.T\GTT-Vandemecum\Help Danny\GTT.chm"
If I run the batch file, the commandline opens but nothing further happens.
If I copy paste S:\G.T.T\GTT-Vandemecum\Help Danny\GTT.chm in start menu/run then it does works.
If I make a shortcut with target "S:\G.T.T\GTT-Vandemecum\Help Danny\GTT.chm" then it also works.
So the command works everywhere, except from a batch file.
What am I doing wrong here ?
It might also be important to know that when I start it from the shortcut, or start menu/runI always get a dialog
We can't verify who created this file. Are you sure you want to open this file ?
I am using Windows 7
EDIT
My problem is not the dialog, my problem is that nothing happens when I open the chm file from a batch file
The Start command is probably seeing your doublequoted string as a title, enter Start /? at the command prompt for its usage information.
Try adding an empty title first:
#Echo Off
Start "" "S:\G.T.T\GTT-Vandemecum\Help Danny\GTT.chm"

Executing a command-line .exe file

I have a .exe file converted from a .jar.
It is a command based application, so I have to start it with a batch script. Here is the batch script:
#echo off
cd C:\desktop\plant-text-adventure-win
start planttextadventure
pause
When I double click on the batch script, this happens: Windows could not find 'planttextadventure'. Please confirm if you have input the correct name and retry.
I don't know what is happening, I have no idea about cmd as I use Mac, but I can confirm I have an executable called planttextadventure.exe in a folder called plant-text-adventure-win.
You should test your batch file by executing it within a shell.
Simply enter within the start menu the command cmd to open up a shell. Within this black box you could now simply enter the commands from your batch script and lookout for some error message.
If you look at your script I would guess that the cd command (to change the current directory) is not correct. Maybe you should replace it with
cd %USERPROFILE%\Desktop\plant-text-adventure-win
because the desktop folder is on a default installation not directly under the root drive but within the user profile available.
Another solution to get this thing to work, is by opening the windows explorer, going to the .exe file you wish to execute and drag & drop the .exe file with a right mouse click onto the desktop.
Then a context menu appears and you select the option Create shortcut here.

Is it possible to make a batch file launch a separate batch file

I have a elevated batch file and I want it to execute a different batch file in a separate window I need to know if it is possible and how to do it. Can any one help.
Yes, if you want to launch a file, say sample.bat, you can use
start "Title" cmd /c sample.bat
Title is the title text I want to display for the new window.
You can see the details in Documentation
Enter a START command in an existing command shell, and specify CMD as the command to execute.

Batch file/command to start a program through command line

I have a program which I want to start using the command prompt and at the same time I want to pass 2 parameters to it.
So, for example, when I wanted to start my program I would open the command prompt (in XP: start > run, type cmd, press return) and then type:
c:\rand\anotherfolder\myprogram.exe 10 20
Since I know nothing about batch files, I'm asking two things:
Can I create a batch file to automatize this process?
If yes, how :D?
I'll edit this if you respond to my comment but if you want to simply execute this command via a batch file (and you know nothing about batch files):
Open a text editor (e.g.Notepad)
Type in your command (e.g. c:\rand\aotherfolder\myprogram.exe 10 20)
Save the file as mybatchfile.cmd
Double click the file (in Windows Explorer etc.)

help with windows batch scripting basics - execution and calling a separate executable within the script

Newbie to windows scripting. I need help running the .bat file on the command line so I can test it.
I used Text Document as my editor to create the file (opens up also as Notepad).
I performed file "save as" (ALL FILES). If I open up cmd, I can see the file has a .txt extension (myfile.bat.txt). So if I just type in cmd myfile.bat.txt the editor opens. I am not sure how to execute this correctly.
As for the logic in my batch script, I am basically logging into a remote directory (already created the net mount) and now I want to:
run an executeable file
rename some files.
With some research, I written this so far. I have saved it as a .bat file
# echo off
echo This is a batch file to run an executable and rename some files
pause
--run executable file here, just don't know how to do it
x:
cd x:
rename fileA fileB
Any help, good tips/practice would be great. Thanks.
Type in this command in cmd window:
rename myfile.bat.txt myfile.bat
Now you can run the script by simply invoking:
myfile.bat
or
myfile
(provided there's no myfile.exe or myfile.com in the same directory).
If you need to edit the script further, you can either right click it in Explorer and choose Edit or call the editor from the command window:
notepad myfile.bat
To call a program from the script, simply add its name, if it's in the current directory:
someprogram.exe
or the name with the path, if it's somewhere else:
directory\program.exe
or
d:\directory\program.exe
If the name or the path contain spaces, be sure to enclose the entire name & path string in double quotes:
"d:\directory\program name.exe"
you can just type the full name of the program
eg
"c:\program dir\program.exe"
or you can add the program directory to your path environment variable
set PATH=%PATH%;"c:\program dir"
and just type the program name
program
you can also edit your PATH variable in windows http://support.microsoft.com/kb/310519
NOTE: When you save the file in notepad, you want to save it as filename.BAT and select All Files from the second dropdown. If you don't it still gets saved as a .TXT.
A couple of command to consider:
CSCRIPT cscript /? in CMD
START http://ss64.com/nt/start.html
If you're doing say a VBSCRIPT use CSCRIPT to start it. If you're trying to execute another BATCH script or an EXE, use START

Resources