Windows cannot find the file specified while running an exe from .bat file - powershell

I am trying to run a exe from a .bat file
However, it throws the above error every time I run the .bat file in powershell.
In both the cmd and powershell window it works properly when I navigate to inside the folder and then run the exe file.
My bat file looks like this.
final1.bat
START /w "H:\trunk-2017-10-16" Bootstrapper.exe
Anything I could be missing?

Assuming your executable file is "H:\trunk-2017-10-16\Bootstrapper.exe"
Then you'd need
START /w "" "H:\trunk-2017-10-16\Bootstrapper.exe"
Note that the first quoted argument becomes the window-title.
OR, if you really want "H:\trunk-2017-10-16" to be your window-title, then bootstrapper.exe appears not to be on your path at the present time.

Related

Call multiple .bat from another .bat without waiting for one to finish

So, I want to make a script that will execute 2 .bat files and start some .exe files.
However, the .bat files are supposed to keep running.
I have something like this :
pushd tools\wamp64
start wampmanager.exe
pushd ..\..\server\login
call startLoginServer.bat
pushd ..\test
call startTestServer.bat
start "C:\DEV\P2\Test\client" P2.bin
The problem is that call startLoginServer.bat will not exit and therefore, I'm stucked here.
How can I run my 2 .bat files and let them keep running.
(Ideally, I want them to run in 2 different command prompt windows)
Also, there is probably a better way to handle relative path than using pushd if you can correct me on this.
Thanks
You could use:
start "Wamp Manager" /B /D "%~dp0tools\wamp64" wampmanager.exe
start "Login Server" /B /D "%~dp0server\login" startLoginServer.bat
start "Test Server" /B /D "%~dp0server\test" startTestServer.bat
start "Text Client" /B /D "%~dp0" "C:\DEV\P2\Test\client.exe" P2.bin
Run in a command prompt window start /? for help on this command explaining the options.
"..." ... title for new console window which is optional, but must be often specified on program to start is or must be enclosed in double quotes. The START command in last command line in batch file code in question interprets C:\DEV\P2\Test\client as window title. It is also possible to use an empty window title, i.e. "" which is best if the started application is a Windows GUI application on which no console window is opened at all.
/B ... run without opening a new window, i.e. in "background". This option can be omitted to see what the started applications and batch files output to console if the executables are not Windows GUI applications.
/D "..." or also /D"..." defines the directory to set first as current directory before running the command specified next. %~dp0 references the directory of the batch file containing these commands. This path always ends with a backslash. Therefore no backslash must be added on concatenating the directory of the batch file with a file or folder name or path.
Run in a command prompt window call /? for help on %~dp0 explaining how arguments of a batch file can be referenced from within a batch file.
See also the answer on How to call a batch file that is one level up from the current directory? explaining in total four different methods to call or run a batch file from within a batch file.
Finally read also the Microsoft documentations about the Windows kernel library function CreateProcess and the structure STARTUPINFO used by cmd.exe on every execution of an executable without or with usage of its internal command start. The options of start become more clear on having full knowledge about the kernel function and the structure used on Windows to run a program.

cmd file that starts plink.exe from a nant script not working

I have a .cmd file that start plink.exe and runs several commands.
This works great if I open a command prompt and run the .cmd file.
It does not work when I call the .cmd file from an nant script.
Oh. the nant script is on a windows machine and the plink.exe is connecting to a linux machine.
Any ideas?
Is the NANT script running under the same user, when you manually run it? Make sure the user's have enough access rights.
Do you notice any error messages? Perhaps it is not founding the command executable i.e. plink.exe in the PATH environment variable.
You can put following in your .cmd file:
echo %PATH%
Compare what you get when you run directly on the prompt and run through nant script. Please also provide the plink command line you are using in the .cmd file.

lost PATH while trying to set custom winlogon shell in WindowsXP

I have changed the shell key in windows registry to gain custom shell (Kiosk usage):
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows
NT\CurrentVersion\Winlogon]
I set shell key to a batch file which runs two applications as below:
start "myFirstAppTitle" "myAppPath\myApp1.exe"
start "mySecondAppTitle" "myAppPath\myApp2.exe"
Each application runs but the second application which needs some files to be excuted throws an error which says could not find dependency files. whereas the dependency files are adjoining to the exe file and the mentioned app works fine, when starts from startup.
Meanwhile when i run the batch file manually it rusn fine.
I added the PATH command to the batch file but it did't work too.
Change the batch file to this:
set PATH=%PATH%;C:\MyAppPath
start "myFirstAppTitle" "myApp1.exe"
start "mySecondAppTitle" "myApp2.exe"
If you start executables without an absolute path, the path is relative to the current working directory. Also, when you specify an executable with a relative path, %PATH% is not searched for a matching subfolder with a matching executable.
Since the script worked when you manually started it, your working directory probably was C:\. However, when run at logon as a replacement shell, the working directory is most likely "%SystemRoot%\system32".
The problem solved strangely, i removed the title parameter of start command and it worked. In fact i used start command this fashion:
set PATH=%PATH%;C:\MyAppPath
start myapp.exe
start myapp2.exe

try run to `eof script batch file` (.bat)

I have scrip contain command line:
set dir=%1
cd %dir%
test.bat
echo successful
When run this script, file test.bat (this file run phpunit) run complete then this script don't run command line echo successful.
So, how to try run to eof script.
Use call test.bat.
When you try running a batch file from another batch like in your question control does not pass back to your calling batch.
Side note: I'd usually use pushd/popd for going into directories from batch files. At least I prefer when a batch file doesn't have a side-effect on the shell I'm working on (similar rationale for setlocal). Also this solves the problem when you pass a directory on another drive (although you could do cd /d in that case.

Run a exe file through a power shell script

I want to run a power shell script which can run a exe file and following are my requirements.
I have that exe file in a remote server location(//ES-WEBSRV01/DBMigration) which is shared to my local machine. Also I want to run that ps file through a cmd.exe.
You can simply call it like any other program:
\\ES-WEBSRV01\DBMigration\something.exe
or, if it contains spaces somewhere along the path:
& "\\ES-WEBSRV01\DBMigration\some thing.exe"
I have no clue what you mean by »Also I want to run that ps file through a cmd.exe.«, though. If you mean that you need a batch file and want to run the PowerShell script from there, then:
powershell -file myscript.ps1