Converting multiple command prompt commands to a batch file - windows

I just started with using batch files, my whole purpose of using them is to save the time I spend running the same commands(command line) and process (making moving folders)
Let me ask on a specific example for now:
I want to run this two commands in a single batch file
cd c:dir\..\dir\bin
prompt:
:WSDL.bat -o C:\somepatch\..\dir -uri someURL.xml
now instead of writing this three commands individually , I want them written on a single batch file , which would run every time the batch file is run.
I tried bunch of things ,but didn't really work out

Related

How to check if a program is already running within a batch script

I want to make a batch file to run a couple of programs but I also want to add a built in check for one of the two to not run if it's already open, since it I use it with other programs as well.
This is my current code without the check:
#echo off
cd "B:\Program Files (x86)\Borderless Gaming
start BorderlessGaming.exe"
cd "B:\Games\Madden NFL 20
start Madden20.exe"
exit

.bat file runs other .bat file unexpectedly [duplicate]

This question already has answers here:
What's the relative order with which Windows search for executable files in PATH?
(3 answers)
Closed 3 years ago.
I created the following TcpConn.bat script that gets the information on open tcp connections from an android device, with an interval of two seconds, running in the adb shell.
:startTCP
adb shell cat /proc/net/tcp
timeout /t 2
goto startTCP
When testing this in my /dev/test/ folder the script ran as expected and gave me the expected output of sl local_address rem_address st tx_queue rx_queue tr tm->when retrnsmt uid timeout inode.
However when I moved it to my /dev/batchFiles/ folder it started running the contents of a different .bat script in that folder (called adb.bat). with the contents
cd C:\Android\sdk\platform-tools
adb logcat -s Unity PackageManager dalvikvm DEBUG
Now in my TcpConn.bat script I execute "adb shell...", which matches the name of "adb.bat" without the extension, so it seems to make a call to this.
My question is though, why would it execute that script? I don't want it to execute the script, but run the adb command
I'm not:
providing the complete filepath/filename (which would be c:/dev/batchFiles/adb.bat), nor am I using it as a string like "adb"
I'm not using call as explained here
not using start
Do batch scripts always check the directory for a file matching part of a command and run that file, even if it doesn't have an extension appended to it? If so is there a way to disable this behaviour?
I'm aware I can just rename the "adb.bat" file and be done with it. But want to know why it gets run.
The only thing i could somewhat related to this is "How to run batch script without using *.bat extension"
As long as there is a batch file in the same directory as the one you are executing then it will execute that adb.bat file because the windows command prompt will look in the current directory first in search of an executable when you tell your batch file to execute a command.
As far as a solution to your problem I would say if it is possible then change the name of your adb.bat file to something else like adbFile.bat that way you won't be calling it every time you need to call your adb tools from that specific directory.

Running Tensorboard using a batch file

to use Tensorboard I need each time to start cmd and than type the TB command and copy and past the logfiles directory.
I was wondering if this could be avoid by using a batch file that could be generated each time.
To test that I've wrote a small batch file that should start Tensorboard with a specific logdir as followed :
Tensorboard --logdir=D:\Tensorflow\Main\Features_selection\Deep_normed_Feature2
PAUSE
The logdir is fine and I can start TB manually, but when I run the batch file I get a loop effect that I don't how to avoid. here is the command prompt output
Does anyone here know how to solve this ?
If you name a batch with the same name as the program run
and don't supply an extension,
you create an infinitive loop the batch running itself constantly.
So either choose a different name or explicitly run the program with full path and extension

Create log file when running a windows script file

I am running a windows script file, via a task scheduler, which carries out some basic tasks. I need to record each command in a temporary log file.
I have seen some examples on the web, but most seem to suggest having each command line tagged with the >> marker. This is tedious for my scripts, have over 100 commands.
Is there a way to do what I want to do, with some global commands in the script file
Many thanks
ash

How to create an executable command prompt script

I usually perform actions in the 7zip command line program. I was thinking about creating a small script to do everything automatically, but I have never written any Windows shell script before and therefore don't even know where to begin.
I would like to make an executable script file which, when a user double-clicks on it, will call the 7zip command line and perform some actions.
First of all, is this possible? And if it is, what is the best way to do this?
You can create a batch script to do this.
It's basically command line commands that run one after another so you don't have to keep typing them in :)
Put the commands you would normally use for 7zip in a notepad file and save it with the extension .bat, then run it.
7z blah blah params
7z more params and args
All your commands will be executed automatically when the previous one finishes.
There are other programming languages you could do this in (or even VBScript) but batch would be perfectly suited to this, and you don't need to install anything extra.
Batch files can run a series of command line commands. Simply create a text file and name it with the .bat extension.
There are plenty of resources on the internet which will provide you with help.

Resources