简体   繁体   中英

How to execute a command from a certain directory in Inno Setup script

I have multiple cmd commands which is about installing npm components. I don't want to use batch file for this purpose. How can I execute these commands through Exec function in an Inno Sectum script and I want the installer to wait until these commands get executed?

Here are some example commands I wish to execute also they need to be executed on specified directory:

npm install forever-monitor
npm install ip

Inno Setup Exec function takes WorkingDir as the third parameter.

So you can do

Exec('npm', 'install forever-monitor', ExpandConstant('{pf}\nodejs'),
     SW_HIDE, ewWaitUntilTerminated, ResultCode);

Though in this case, I would question, whether npm really needs to be executed from its directory. It is likely, that all you actually need is to execute npm with a full path:

Exec(ExpandConstant('{pf}\nodejs\npm'), 'install forever-monitor', '',
     SW_HIDE, ewWaitUntilTerminated, ResultCode);

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