Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use Grunt to spawn a windows command line with special character?

I'm on windows. To build my application I used to do a lot of manual file manipulations and, at the last step, to run this command:

"c:\Program Files\Inno Setup 5\ISCC.exe" /dType=server /dBits=32 /dArchAllowed="x86 x64" config.iss

Please note that the /d option is to pass some custom variables to Inno Setup.

Recently things changed and we decided to automate the task using Grunt. All the file manipulations are working fine. But I'm not able to do the last step (to run the command line) correctly.

I tried:

grunt.task.registerTask('create-exe', 'create the installer', spawnTask({
    cmd: 'c:\\Program Files\\Inno Setup 5\\ISCC.exe', 
    args: ['/dType=server' , '/dBits=32' ,'/dArchAllowed="x86 x64"', 'config.iss' ]
}));

But Inno Setup is not happy:

stderr: 'Error on line 38 in config.iss: 
Value of [Setup] section directive "ArchitecturesAllowed" is invalid.',

So, something is wrong with the argument /dArchAllowed="x86 x64" (and if I remove it it is running. But I need this argument.) It's a nasty one: it has double quotes, equal and space! I tried a lot of combinations to escape the special characters but without success.

Any Idea? Thanks!

like image 437
Jason Avatar asked Dec 11 '25 11:12

Jason


1 Answers

I found the answer on this help page.

The /d command line compiler parameter values cannot be surrounded by double quotes. So, I just replaced '/dArchAllowed="x86 x64"' with '/dArchAllowed=x86 x64' in the args property.

The whole grunt task is:

grunt.task.registerTask('create-exe', 'create the installer', spawnTask({
    cmd: 'c:\\Program Files\\Inno Setup 5\\ISCC.exe', 
    args: ['/dType=server' , '/dBits=32' ,'/dArchAllowed=x86 x64', 'config.iss' ]
}));
like image 161
Jason Avatar answered Dec 14 '25 02:12

Jason



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!