简体   繁体   中英

How to run a cmd command from bat file?

I need to run this command in the command prompt automatically:

msiexec /i "My application"/qn

How can I write a batch file to do this?

Batch files are, for all intents and purposes, just lists of cmd commands. Just take that command, paste it into notepad, and save it with a .bat extension.

It's generally considered good practice to start the batch script with the line @echo off so that the lines of the script don't display as they're being executed.

@ECHO OFF
msiexec/i "My application"/qn

To run the batch file when the VM user logs in:

Drag batch file itself to Start - All Programs - Startup. Now when you login as that user, it will launch the batch file.

you may find the Batch HowTos helpful.

Examples: see Link

Install:
msiexec /i "C:\Install\ss64app.msi"

 UnInstall:
msiexec /uninstall "{5AFF6499-63BA-4A36-83B2-8D256404AC3D}" /log "C:\install\ss64app.txt"

Autorun

1. create text file

2. edit with Notepad 

[autorun] 
icon=drive.ico
open=launch.bat
open=launch.bat
[autorun]     
open=\folder1\runinstallers.bat
open=\folder2\PLSetup_2.exe  

3. save the file as Autorun.inf
4. copy the Autorun.inf to the root folder of your CD-ROM

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM