Put server on heavy load for testing in Windows - windows

Need to heavily exercise an eight-core server under Windows. Found a Linux exercising test at Put server on heavy load for testing and would like to perform a similar workout using command prompt commands.

Solved: I created a batch file DO.BAT which contains one line
dir /s /r /on & do ^z
and then from within a command prompt window entered
start do
which opened a new command prompt window and launched DO.BAT to loop until a Ctrl-Break is entered. Then, repeated that until many windows were running.
Many thanks to Bali C who mentioned the start command in How to run multiple DOS commands in parallel?

Related

How to work around ebook-convert.exe (in calibre portable) halting batch file execution?

I use ebook-convert.exe from a batch file, and on one of my machines (old Windows vista laptop), any calls ebook-convert.exe prevent further commands in a batch file from running (in that .bat file, or in that cmd shell instance for instance). The conversion to .mobi actually succeeds, prints no errors even in -v -v full verbose mode. I tried versions 1.20.0 and 0.9.6 of calibre portable. It seems to be related to the executable itself, and not to the specific conversion job (just running it with -h flag has same effect). I tried running cmd in administrator mode, wrapping it with 'call' command, nothing helps. Assuming the calibre issue is a black hole that can't be solved, is there a DOS trick I could possibly try to keep batch commands running no matter what odd thing happens with ebook-convert.exe on that machine?
Using call in a batch file should work on normal console programs but it is possible for programs to "escape" if they really want to.
Using Start instead might work but it does not wait by default and its syntax is not sane:
Start /B /WAIT c:\path\without\spaces.exe optionalParameter
or
Start "" /B /WAIT "c:\path\w i t h\spaces.exe" optionalParameter
Remove /B to run the application in a new console.
Another option is to call ping localhost and For (to get the file size with %%~zA) in a loop until the size of the destination file stops increasing. This is a bit of a hack and might not work, it depends on how the converter opens the file and how often it flushes the writes.

How do I tell a windows batch script to execute the next line without waiting for the previous line to finish executing?

I'm setting up a .cmd script to be run on startup for a pseudo-server (It's actually a laptop, but that's irrelevant) to automatically launch pageant, load an SSH key, connect to an SSH server using Putty (Pageant would automatically authenticate with the key), then launch mIRC which in turn has a series of scripts setup to operate as an IRC bot and automatically connect to networks using putty as an SSH tunnel.
With that in mind, I have the below code in a startup.cmd file:
"C:\Program Files (x86)\PuTTY\pageant.exe" c:\Path\To\Private\Key.ppk
"C:\Program Files (x86)\PuTTY\putty.exe" -ssh user#host
"C:\Program Files (x86)\mIRC\mirc.exe"
EXIT
When I test run this file, the command prompt runs the first line, launches pageant, and then sits there and does nothing until I close pageant completely. I believe I have an idea on what the issue here is, but I can't find any information on how to resolve this in a batch file.
I do know on linux systems, if I were running a bash script to do something similar, I would want to have a & symbol at the end of each line to tell it to run the next command without waiting for the previous command to finish executing. I did try that in the batch script in the off chance that would work (It didn't).
For those who may ask, this is on Windows 8.1 64 bit. The user running this script is not an administrator.
I can't comment to expand on Squashman's suggestion, so let me answer here.
In your case, if you only want to have Pageant running in the background, without interacting with it, I think it's best to run:
START "" /B <your command>
The /B parameter will spawn the process without launching a new window for it, which seems like something you'd like to avoid (anyway, it's probably closest to the behaviour you can obtain in Linux with &).
Please note that if you close the window from which you spawned this process, it will terminate as well.

Windows 8.1 batch file - closing separate command window

I'm trying to run a batch file that will close a different cmd window. I know I can do this:
TASKKILL /IM "myapplication.exe" /F
But whilst this does (obviously) kill the task, it doesn't close the cmd window myapplication.exe was running in. I cannot edit myapplication.exe or I would put an 'exit' on the last line.
Any help would be much appreciated.
Well, if your program was started from cmd, then obviously cmd is still running even if you kill or exit that application. To kill cmd as well you can apply the same command to a different program (in a quite obvious way).
However, this will also stop your batch file for equally obvious reasons.
Is there a particular need to run myapplication from cmd?

Running programs via shell

I am running Windows 7x64 and Excel 2010x32. I call 32bit dos programs (written in Fortran) via vba using ExecCmd (a Microsoft function that waits for a command prompt process to finish). I send a command line to this function that explicitly contains the program path and the paths of the input file and output file.
This runs fine on my PC and also on a company PC running the same software (OS and Office) and for which I have general access to the C: drive.
On other company PCs, where there is not general access to the C: drive, this does not work - i.e. the dos programs do not produce an output file. On these PCs, I can still run the program at the command prompt manually. It is just that calling this command prompt does not work via Excel VBA.
Now the strange thing is that I can successfully run one of these programs by adding "cmd.exe /c" at the beginning of the command line. That would appear to be running a command prompt within a command prompt (!). The other program (which, incidentally, is quite a bit bigger) does not work at all via vba on these PCs. I need to be able to provide other employees with something that works.
Can anyone shed some light on what is happening here and suggest a work around? I could past some code, but I think the above should be self explanatory.
You're confusing the command shell with the console window. In this context, the distinction is critical.
Console-mode programs (aka "command-line programs") require a console window to provide input and output. When a console-mode program is launched from a GUI program, Windows automatically creates a console window for it (unless instructed otherwise).
The command shell (aka "Command Prompt") is cmd.exe, a console-mode program.
The important point here is that not every console window has an instance of cmd.exe running in it. When a console-mode program is launched from a GUI program, Windows automatically creates a console window but does not automatically create an instance of cmd.exe. If you want to pass a command to cmd.exe you have to do so yourself, or use a run-time library routine that does it for you.
ExecCmd does not do this; it runs the program directly. So passing cmd /c <command> to ExecCmd is not "running a command prompt within a command prompt" at all. Without the cmd /c you aren't running a command shell command, you're just launching an executable.
There are any number of reasons why the command you're passing might need to be given to the command shell. For example:
it might be a built-in command like dir or type which only exists within the command shell;
it might include redirection or pipelining operators, or environment variable substitution;
it might be a script rather than an executable.
There are other cases. If you show us the command line being passed to ExecCmd we may be able to provide more specific advice. (The fact that the same command line is apparently working on some machines is puzzling, but can't be addressed without more information.)

Windows bat - calling programs for different cmd

I wonder if I can execute some programs for different cmd's using .bat file. Look at this example .bat file:
start cmd //number one
start cmd //number two
ping localhost //call in number one
ping 192.168.1.100 //call in number two
I know that both will be executed in main window (the window where I started .bat file), but I think its easy to get the idea. This code is quite useless, but its just an example.
Thanx for all replies.
EDIT: I know about /k switch, but any way to do this not using it?
You can start your commands with
start cmd /k ping localhost
start cmd /k ping 192.168.1.100
That will start two new command line prompts, run the ping command in each one seperately and both windows and the /k switch will make them stay open afterwards.
Ah, posted before your edit ... ;) The only way to interact with a shell is giving it a command to be executed when it starts. There is no way to have interaction between shells
CMD.EXE has two parameters, /C and /K, which let you specify a command to execute. /C closes the window when the command is finished, whereas /K keeps it running.
If you want to excute multiple commands within a single window, you'll need to concatenate them with && or similar - this will require quoting; CMD /? will tell you all the details on that - or you can have it start a batch file containing the commands.

Resources