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

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.

Related

Continue With CMD Commands After Batch Script

I am trying to write a batch script which, once complete, would allow the user to continue using the Windows command prompt as they normally would had no script been run. Is this possible? Thank you in advance for any help.
If you manually open CMD (the Command Prompt) and invoke the batch file by name, CMD will remain open for additional commands after the batch file completes. You cannot do this by double-clicking on the batch file, but if you create a shortcut to the batch file that runs CMD.EXE with the /K switch, you will run the batch file and then leave CMD running for additional commands. See CMD at SS64.

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"

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

::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"

How do I make a cmd script that once it is run, remains open and accepts new commands?

I want to make a cmd script that performs an action but then remains open and I can type new commands.
I have failed to find the proper terms to google as my knowledge of shell is almost zero.
thank you!
You can specify a command shell to run a specific command during start-up using the /k switch. E.g.
cmd /k C:\InitialScript.bat
The command shell would execute the C:\InitialScript.bat batch file and remain open for the user to type further commands.
If you want to create an icon for users to use then create a shortcut and use the following as the target:
%WINDIR%\System32\cmd.exe /K C:\InitialScript.bat
If you already have a command shell window open, then just use the following which will run the batch file in the context of the existing shell:
C:\InitialScript.bat

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.)

Resources