Command Line in Batch file? - command-line

I am making a batch file to automate mysql installation silently. When I type the following line in the command prompt everything works fine.
"C:\Program Files\MySQL\MySQL Server 5.1\bin\mysqlinstanceconfig.exe" -i -q ServiceName="mydb" RootPassword="pos" ServerType=DEVELOPMENT DatabaseType=INNODB Port=3306
My question is: can I somehow add this to a batch file so it will run it as if I entered it in the command line?
Thanks,
Matt

yes, its easy. As Santa commented, just put your command inside some text file, change the extension of that file to .bat. Thats all !!

Related

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

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.

how to run a cmd file from matlab

I am trying to run a cmd file from MATLAB but unable to execute it. Can anybody see nay problem in the below code?
this is what I have inside my cmd file:
echo on
>test.log 2>&1 (
C:/testProj/Make/makeit.cmd param1
)
And this is the MATLAB code:
Out = 'C:/testProj/test.cmd';
system(Out);
But this actually does not run the cmd file.
Well for somereason it would not run if i would give the complete path of the cmd in bat file. so I had a cd command to change the directory and then run. now it runs fine, Thanks all appreciate your help!
What about using eval, like this:
eval(['!test.cmd']);
I have succesfully used this to run .bat files (and this output of the .bat script showed in my matlab command line). I also found this dos command, but I am not sure if it works allright:
You can just type the following strings to get things down:
!(c:/testProj/test.cmd)
This is actually no different from
system('c:/testProj/test.cmd')
I think you should check if the path is wrong. As to your code in the cmd file, that's beyond my ability to help.

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.

copy command syntax error in Windows XP

Basically I am just trying to create a batch file to copy one file from one location to another location in Windows XP like the code below but failed. May I know why?
copy C:/Directory_A/the_file D:/Directory_B
When I execute the batch file I see this in the output:
The syntax of the command is incorrect.
Try using backslashes
copy C:\Directory_A\the_file D:\Directory_B

Cannot Execute FTP commands through ClearCase trigger

I have a ClearCase trigger that runs a .bat file and it works perfectly. What I want to do now is have it run some FTP commands, in my case using WinSCP. I have a command ready in another .bat file which, when run manually, works. When I invoke this .bat file from the .bat launched by the ClearCase trigger, however, it does not work. I have no idea why!
The command in the triggered .bat file is call ftp.bat.
Any ideas? Could it be permissions?
Thanks,
Andrew
As the OP Andrew reports, WinSCP isn't practical when called from another bat.
This would not run:
"C:\Program Files\WinSCP\winscp.com" /script=sftp_script.txt
However, this will, based on psftp (from PuTTY):
echo y | psftp %FTPUSER%#%FTPSERVER% -pw %FTPPASS% -b psftp_script.txt