How to use batch file to launch cmd silently? - batch-file

I am trying to use my batch script to call upon a cmd to uninstall a program.
install -u
Is there a way which I can use my batch script to execute this cmd silently? Meaning it wont pop up.
Thanks!

start /min install -u
or if it's a command-line program
start /min cmd /c install -u

Related

How do I execute cmd commands through a bat file?

I need to create a .bat to put together with my setup system to install a network driver, but I have some difficulties in creating the bat.
This .bat needs:
execute a cmd with administrator privileges
run this command: netcfg.exe -v -l networkbll_lwf.inf -c s -i nt_networkbll
exit
The folder for all files location is: c:\Windows\System\Drivers.
You might have to use another batch file first to launch the second with admin rights.
In the first use
runas /noprofile /user:mymachine\administrator batchfilename.bat
PAUSE
and write the needed command in another bat file

.bat file running cmd with specific command lines

I need to create a batch file that will open cmd.exe (as a administrator) with these lines:
cd C:\Program Files\Putty
cd C:\Program Files\Putty>psftp -i XXXXXXXXX.ppk xxxx_test#111.111.111.11 -b C:\UPLOAD\upload.ftp
Can anyone help me?
DoStuff.bat
#echo off
runas /user:%USERDOMAIN%\%USERNAME% "cmd.exe /K \"cd C:\Program Files\Putty\" & psftp -i XXXXXXXXX.ppk xxxx_test#111.111.111.11 -b C:\UPLOAD\upload.ftp"
runas will let you run a command as Administrator (you may need to change the domain/user to match your system, and enter a password).
Running cmd.exe /K will run the following commands.
The quotes around the commands need to be escaped with \"
I'm having a hard time seeing the difficulty.
Can you explain what you tried, and why it didn't work?

Run a command promt and run a command

I need to write a command which is calling other command prompt of Oracle and running a command on it. Currently, I am running it using below command
D:\Oracle\setenv.bat /k BuildApp
But it only runs setenv.bat and quits and doesn't run BuildApp. BuildApp is to run on a command prompt opened by setenv.bat. Can anyone please help on this?
Try CMD /c d:\Oracle\setenv.bat /k BuildApp.

How to run 'cfx xpi' after 'activate' via .bat?

I'm trying to automatize installing of my addon. Mozilla says that it's very simple, but:
I didn't find any while loops in .bat files or sleep for milisec.
I can't understand, how to use activate.bat and cfx xpi in one CMD window sequentially, and also use wget in other CMD after all.
How can I do even if second part? I've tried something like:
START cmd /K "activate "cfx xpi"" && wget --post-file=tst-closing-cur-tab.xpi http://localhost:8888/
or
START cmd /K "activate && "cfx xpi"" && wget --post-file=tst-closing-cur-tab.xpi http://localhost:8888/
but it always run cfx in CMD, not in 'virtual CMD' after activate
I use this
call "c:\Firefox\Sdk\bin\activate.bat"
cd c:\dev-1.0.2.5-firefox\
cfx xpi

MSBuild PSExec hangs without error while executing batch file

As part of as our Team Build MSBuild script, we have a deployment batch file which I need to execute on a remote server:
<Exec Command="psexec -accepteula \\servername D:\Build_Drop\DeploySites.bat "/>
I can confirm it is not permissions or firewall: if the bat command is changed to run iisreset or calc.exe for example, the command will work.
I have tried -s and >nul flags, and also wrapping the batch file in a call to cmd. I have tried with and without quotes around the bat cmd.
All the options I have tried will work fine from the cmd line on the build server, but none will work from within the build script itself.
Any ideas?
Adding a -i parameter to psexec seems to have worked.
Oddly, we now get the error message:
The command "psexec -accepteula \\server -i cmd /c "D:\Build_Drop\DeploySites.bat"" exited with code 5. Please verify that you have sufficient rights to run this command.
But the command does actually work

Resources