-new_console not recognized when used on a batch file - conemu

I have a set of batch files. Some of them are shortcuts to long running tasks, like an FTP server. I want to launch them in a separate tab, so that I can look at the output later. I've found the -new_console option, but it doesn't seem to work on batch files (while it does work on plain executables) - ftp.bat -new_console will run in the same console.
Is this by design? If so - is there a workaround?
UPD1: As I suspected, cmd /c ftp.bat -new_console did work. Looks like ConEmu doesn't count .bat or .cmd as executables. Though, the question remains the same.

When you type in your prompt "ftp.bat" cmd don't start new process, it reads file and execute it contents internally.
ConEmu process "-new_console" when shell create new process only.
So, if you need to start cmd/bat in new console - use "cmd /c " or alias for example. Also, you may use "-new_console" inside of batch file, when you starting ftp or any other process.

Related

How do I make a batch file that opens Task Manager?

So i have been looking for this on this website and cannot seem to find it so im asking you how to do it
If you are looking to display a list of processes from the command prompt you can use TaskList.exe if you are looking to just open the windows Task Manager you can use TaskMgr.exe
For standard batch file you would just use tasklist.exe. If you were using powershell you would use start-process tasklist.exe -nonewwindow.
I created a batch file to start several programs, including Task Manager. I used this code:
cd C:\ProgramData\Microsoft\Windows\Start Menu\Programs
start taskmgr
if this path does not work for you, right click on the task manager app and look at the path in the "properties"
start taskmgr
should work :)
(tested, it works!)
You can use this with a batch file: start "" TaskMgr.exe
I tried it on Windows 11, it worked fine.

Setting user name and password to browser from the Batch file

I have created a batch file to open a browser. But I need to know how to interpret the user name and password from the batch file.
Below is my batch file. Can anyone please help?
FYI, I'm just using the normal .bat file (from notepad).
#ECHO ON
start /d "C:\Program Files\Internet Explorer" IEXPLORE.EXE https://www.myhcl.com/Login/home.aspx
There is no "native" way for a bat file to interact with a window. I would use powershell or VB script for this task but it will be quite a mess.
An easy way is to use AutoIt. It's realy simple and allows you to fully interact with a browser. You could ither use the AutoIt interpreter from within your bat file to manipulate the browser window or just create an au3 or even an exe file that starts the browser and enters the login data.
If you decide to use AutoIt and need help with the script just ask me.

Pipe command to specific cmd.exe

So I've written a .bat file (later on refered to as the 2nd one) to backup files every night and then weekly offsite to ensure the files aren't lost. However I realized that a process may be running and currently editing the files so it'd be best to shut down the process and then start it again once the backup is done.
Now, the main problem is this: The process is another batch file running under cmd.exe. There is also a java.exe command window that is created in conjunction with the cmd.exe, and entering the stop into either the cmd.exe or java.exe windows produces the same and the process will stop their process safely. With that in mind I've tried the following commands (minus the *s),
echo stop | cmd.exe
echo stop | java.exe
but what I find is that the cmd.exe pipe is just sending the command to the command window opened by the 2nd batch file. Meanwhile the java.exe command returns an error in the 2nd batch file on how that the proper parameters weren't used.
That being said my main question is this:
Is it possible to pipe commands to specific cmd windows, if so how?

Using a batch file on Desktop to start shortcut on AllUsersDesktop

I use a remote support program to access agent's computers to set them up to work with our dialer.
I use a script via that remote program that adds IE shortcuts to their desktop. To make this script work for any variety of computer setups, the shortcuts are created on the AllUsersDesktop.
I also install a program (called Ventrilo) that creates a shortcut on the specific desktop they are on when I remote into their system.
I would like to add a batch file they can execute that will automatically open the shortcut to Ventrilo and open the IE shortcut on the AllUsersDesktop.
The batch file I have is as follows:
#echo off
start Ventrilo.lnk
start Shortcut.lnk
This opens Ventrilo but not the Shortcut. I am certain it is because the Shortcut is on the AllUsersDesktop, while the shortcut to Ventrilo is not. However, I cannot figure out how to use that start command in conjunction with %AllUserDesktop%
%allusersprofile%\desktop\shortcut.lnk
Type set in a command prompt.
You can start IE by calling start on iexplore, no need to run the shortcut.
start iexplore
Alternatively GoughW's answer should do the trick to.
Make sure you have an end line at the end of your
start shortcut.lnk
in your batch file.

How to write a batch file to run applications opening in different command prompts?

I would like to run three servers on my Windows machine from command prompt. For this I would like to write a batch file to run these opening three different command prompts.
To generate 3 new CMD windows that remain open, use the following command syntax:
start "application1" cmd.exe /k dir *.exe
start "application2" cmd.exe /k dir *.xml
start "application3" cmd.exe /k dir *.bat
Where the command after /k is whatever application command line that you want to launch.
Replace the "application#" with some TITLE for the window, that makes sense for you (otherwise it will just say something like C:\Windows\System32\CMD.exe).
The windows will stay open, but that doesn't mean your application will still be running. Like the Dir examples above, it may end but the window will remain.
The full command syntax for START is found here.
The full command syntax for CMD is found here.
Why batch?
If you can, my best suggestion would be to ditch batch and download cygwin in order to use bash instead.
You will find bash much more flexible, used (which means you are far more likely to get support from others), and supported.
I am a windows user and tried to learn batch some time ago, but it was really really frustrating. bash is so much more user friendly.
This should do what you want
start application1
start application2
start application3
This will start 3 applications which will open with 3 different command prompts, whether or not they will keep running or not will depend on the app.

Resources