Including a bat with arguments (that launchs a cmd window and adds commands to the path) into another bat












1















I have a bat file running a command :



C:WindowsSystem32cmd.exe /E:ON /V:ON /K ""C:Program Files (x86)pathtothecompilersscript.bat" option1 option2"


It basically opens a cmd windows for which different commands (intel compilers etc) are already in the path. Then, in this command window I cd to a specific location and I use these intel commands as follows :



ifort -c -fpp file1.f90
ifort -c -fpp file2.f90
ifort -c -fpp file3.f90
ifort -dll -o libfinal.dll file1.obj file2.obj file3.obj
lib /out:./libfinal.lib file1.obj file2.obj file3.obj
xcopy /s .libfinal.dll "..libfinal.dll*" /Y
xcopy /s .libfinal.lib "..libfinal.lib*" /Y


which compile (with ifort intel fortran compiler, but the question doesn't depend on it) libraries and copies them somewhere.



I would to wrap all above into a single bat file doing the whole job. I came up with :



call ""C:Program Files (x86)pathtothecompilersscript.bat" option1 option2"
ifort -c -fpp file1.f90
ifort -c -fpp file2.f90
ifort -c -fpp file3.f90
ifort -dll -o libfinal.dll file1.obj file2.obj file3.obj
lib /out:./libfinal.lib file1.obj file2.obj file3.obj
xcopy /s .libfinal.dll "..libfinal.dll*" /Y
xcopy /s .libfinal.lib "..libfinal.lib*" /Y


but running it gives me the following :



'""C:Program' is not recognized as an internal or external command


I checked Command Prompt Error 'C:Program' is not recognized as an internal or external command, operable program or batch file but did not succeed in adapting to my situation



Remark. option1 and option2 don't have spaces or anything requiring quoting, and if I use call "C:Program Files (x86)pathtothecompilersscript.bat" option1 option2 I have the following error :



The input line is too long.
The syntax of the command is incorrect.


Remark. The true content of the call line is :



call "C:Program Files (x86)IntelSWToolscompilers_and_libraries_2017.4.210windowsbinipsxe-comp-vars.bat" intel64 vs2015









share|improve this question




















  • 2





    Did you try adjusting the quoting, e.g. Call "C:Program Files (x86)pathtothecompilersscript.bat" option1 option2. If one or both of the options require quoting you could additionally try doing so thus, Call "C:Program Files (x86)pathtothecompilersscript.bat" "option1" "option2".

    – Compo
    Jan 2 at 14:14













  • Yes I did (option1 and option2 do not require quoting) and had The input line is too long. The syntax of the command is incorrect.

    – 11house
    Jan 2 at 14:29











  • As we cannot see the true content of your path or your options, my only advice would be to first, PushD or CD to "C:Program Files (x86)pathtothecompilers", then try Call script.bat option1 option2. If you chose PushD, then you may wish to add, PopD, to the next line after the Call line.

    – Compo
    Jan 2 at 15:32











  • @Compo Updated my question with the true content of the call line

    – 11house
    Jan 2 at 15:37
















1















I have a bat file running a command :



C:WindowsSystem32cmd.exe /E:ON /V:ON /K ""C:Program Files (x86)pathtothecompilersscript.bat" option1 option2"


It basically opens a cmd windows for which different commands (intel compilers etc) are already in the path. Then, in this command window I cd to a specific location and I use these intel commands as follows :



ifort -c -fpp file1.f90
ifort -c -fpp file2.f90
ifort -c -fpp file3.f90
ifort -dll -o libfinal.dll file1.obj file2.obj file3.obj
lib /out:./libfinal.lib file1.obj file2.obj file3.obj
xcopy /s .libfinal.dll "..libfinal.dll*" /Y
xcopy /s .libfinal.lib "..libfinal.lib*" /Y


which compile (with ifort intel fortran compiler, but the question doesn't depend on it) libraries and copies them somewhere.



I would to wrap all above into a single bat file doing the whole job. I came up with :



call ""C:Program Files (x86)pathtothecompilersscript.bat" option1 option2"
ifort -c -fpp file1.f90
ifort -c -fpp file2.f90
ifort -c -fpp file3.f90
ifort -dll -o libfinal.dll file1.obj file2.obj file3.obj
lib /out:./libfinal.lib file1.obj file2.obj file3.obj
xcopy /s .libfinal.dll "..libfinal.dll*" /Y
xcopy /s .libfinal.lib "..libfinal.lib*" /Y


but running it gives me the following :



'""C:Program' is not recognized as an internal or external command


I checked Command Prompt Error 'C:Program' is not recognized as an internal or external command, operable program or batch file but did not succeed in adapting to my situation



Remark. option1 and option2 don't have spaces or anything requiring quoting, and if I use call "C:Program Files (x86)pathtothecompilersscript.bat" option1 option2 I have the following error :



The input line is too long.
The syntax of the command is incorrect.


Remark. The true content of the call line is :



call "C:Program Files (x86)IntelSWToolscompilers_and_libraries_2017.4.210windowsbinipsxe-comp-vars.bat" intel64 vs2015









share|improve this question




















  • 2





    Did you try adjusting the quoting, e.g. Call "C:Program Files (x86)pathtothecompilersscript.bat" option1 option2. If one or both of the options require quoting you could additionally try doing so thus, Call "C:Program Files (x86)pathtothecompilersscript.bat" "option1" "option2".

    – Compo
    Jan 2 at 14:14













  • Yes I did (option1 and option2 do not require quoting) and had The input line is too long. The syntax of the command is incorrect.

    – 11house
    Jan 2 at 14:29











  • As we cannot see the true content of your path or your options, my only advice would be to first, PushD or CD to "C:Program Files (x86)pathtothecompilers", then try Call script.bat option1 option2. If you chose PushD, then you may wish to add, PopD, to the next line after the Call line.

    – Compo
    Jan 2 at 15:32











  • @Compo Updated my question with the true content of the call line

    – 11house
    Jan 2 at 15:37














1












1








1








I have a bat file running a command :



C:WindowsSystem32cmd.exe /E:ON /V:ON /K ""C:Program Files (x86)pathtothecompilersscript.bat" option1 option2"


It basically opens a cmd windows for which different commands (intel compilers etc) are already in the path. Then, in this command window I cd to a specific location and I use these intel commands as follows :



ifort -c -fpp file1.f90
ifort -c -fpp file2.f90
ifort -c -fpp file3.f90
ifort -dll -o libfinal.dll file1.obj file2.obj file3.obj
lib /out:./libfinal.lib file1.obj file2.obj file3.obj
xcopy /s .libfinal.dll "..libfinal.dll*" /Y
xcopy /s .libfinal.lib "..libfinal.lib*" /Y


which compile (with ifort intel fortran compiler, but the question doesn't depend on it) libraries and copies them somewhere.



I would to wrap all above into a single bat file doing the whole job. I came up with :



call ""C:Program Files (x86)pathtothecompilersscript.bat" option1 option2"
ifort -c -fpp file1.f90
ifort -c -fpp file2.f90
ifort -c -fpp file3.f90
ifort -dll -o libfinal.dll file1.obj file2.obj file3.obj
lib /out:./libfinal.lib file1.obj file2.obj file3.obj
xcopy /s .libfinal.dll "..libfinal.dll*" /Y
xcopy /s .libfinal.lib "..libfinal.lib*" /Y


but running it gives me the following :



'""C:Program' is not recognized as an internal or external command


I checked Command Prompt Error 'C:Program' is not recognized as an internal or external command, operable program or batch file but did not succeed in adapting to my situation



Remark. option1 and option2 don't have spaces or anything requiring quoting, and if I use call "C:Program Files (x86)pathtothecompilersscript.bat" option1 option2 I have the following error :



The input line is too long.
The syntax of the command is incorrect.


Remark. The true content of the call line is :



call "C:Program Files (x86)IntelSWToolscompilers_and_libraries_2017.4.210windowsbinipsxe-comp-vars.bat" intel64 vs2015









share|improve this question
















I have a bat file running a command :



C:WindowsSystem32cmd.exe /E:ON /V:ON /K ""C:Program Files (x86)pathtothecompilersscript.bat" option1 option2"


It basically opens a cmd windows for which different commands (intel compilers etc) are already in the path. Then, in this command window I cd to a specific location and I use these intel commands as follows :



ifort -c -fpp file1.f90
ifort -c -fpp file2.f90
ifort -c -fpp file3.f90
ifort -dll -o libfinal.dll file1.obj file2.obj file3.obj
lib /out:./libfinal.lib file1.obj file2.obj file3.obj
xcopy /s .libfinal.dll "..libfinal.dll*" /Y
xcopy /s .libfinal.lib "..libfinal.lib*" /Y


which compile (with ifort intel fortran compiler, but the question doesn't depend on it) libraries and copies them somewhere.



I would to wrap all above into a single bat file doing the whole job. I came up with :



call ""C:Program Files (x86)pathtothecompilersscript.bat" option1 option2"
ifort -c -fpp file1.f90
ifort -c -fpp file2.f90
ifort -c -fpp file3.f90
ifort -dll -o libfinal.dll file1.obj file2.obj file3.obj
lib /out:./libfinal.lib file1.obj file2.obj file3.obj
xcopy /s .libfinal.dll "..libfinal.dll*" /Y
xcopy /s .libfinal.lib "..libfinal.lib*" /Y


but running it gives me the following :



'""C:Program' is not recognized as an internal or external command


I checked Command Prompt Error 'C:Program' is not recognized as an internal or external command, operable program or batch file but did not succeed in adapting to my situation



Remark. option1 and option2 don't have spaces or anything requiring quoting, and if I use call "C:Program Files (x86)pathtothecompilersscript.bat" option1 option2 I have the following error :



The input line is too long.
The syntax of the command is incorrect.


Remark. The true content of the call line is :



call "C:Program Files (x86)IntelSWToolscompilers_and_libraries_2017.4.210windowsbinipsxe-comp-vars.bat" intel64 vs2015






windows batch-file cmd windows-10






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 2 at 15:36







11house

















asked Jan 2 at 14:08









11house11house

325




325








  • 2





    Did you try adjusting the quoting, e.g. Call "C:Program Files (x86)pathtothecompilersscript.bat" option1 option2. If one or both of the options require quoting you could additionally try doing so thus, Call "C:Program Files (x86)pathtothecompilersscript.bat" "option1" "option2".

    – Compo
    Jan 2 at 14:14













  • Yes I did (option1 and option2 do not require quoting) and had The input line is too long. The syntax of the command is incorrect.

    – 11house
    Jan 2 at 14:29











  • As we cannot see the true content of your path or your options, my only advice would be to first, PushD or CD to "C:Program Files (x86)pathtothecompilers", then try Call script.bat option1 option2. If you chose PushD, then you may wish to add, PopD, to the next line after the Call line.

    – Compo
    Jan 2 at 15:32











  • @Compo Updated my question with the true content of the call line

    – 11house
    Jan 2 at 15:37














  • 2





    Did you try adjusting the quoting, e.g. Call "C:Program Files (x86)pathtothecompilersscript.bat" option1 option2. If one or both of the options require quoting you could additionally try doing so thus, Call "C:Program Files (x86)pathtothecompilersscript.bat" "option1" "option2".

    – Compo
    Jan 2 at 14:14













  • Yes I did (option1 and option2 do not require quoting) and had The input line is too long. The syntax of the command is incorrect.

    – 11house
    Jan 2 at 14:29











  • As we cannot see the true content of your path or your options, my only advice would be to first, PushD or CD to "C:Program Files (x86)pathtothecompilers", then try Call script.bat option1 option2. If you chose PushD, then you may wish to add, PopD, to the next line after the Call line.

    – Compo
    Jan 2 at 15:32











  • @Compo Updated my question with the true content of the call line

    – 11house
    Jan 2 at 15:37








2




2





Did you try adjusting the quoting, e.g. Call "C:Program Files (x86)pathtothecompilersscript.bat" option1 option2. If one or both of the options require quoting you could additionally try doing so thus, Call "C:Program Files (x86)pathtothecompilersscript.bat" "option1" "option2".

– Compo
Jan 2 at 14:14







Did you try adjusting the quoting, e.g. Call "C:Program Files (x86)pathtothecompilersscript.bat" option1 option2. If one or both of the options require quoting you could additionally try doing so thus, Call "C:Program Files (x86)pathtothecompilersscript.bat" "option1" "option2".

– Compo
Jan 2 at 14:14















Yes I did (option1 and option2 do not require quoting) and had The input line is too long. The syntax of the command is incorrect.

– 11house
Jan 2 at 14:29





Yes I did (option1 and option2 do not require quoting) and had The input line is too long. The syntax of the command is incorrect.

– 11house
Jan 2 at 14:29













As we cannot see the true content of your path or your options, my only advice would be to first, PushD or CD to "C:Program Files (x86)pathtothecompilers", then try Call script.bat option1 option2. If you chose PushD, then you may wish to add, PopD, to the next line after the Call line.

– Compo
Jan 2 at 15:32





As we cannot see the true content of your path or your options, my only advice would be to first, PushD or CD to "C:Program Files (x86)pathtothecompilers", then try Call script.bat option1 option2. If you chose PushD, then you may wish to add, PopD, to the next line after the Call line.

– Compo
Jan 2 at 15:32













@Compo Updated my question with the true content of the call line

– 11house
Jan 2 at 15:37





@Compo Updated my question with the true content of the call line

– 11house
Jan 2 at 15:37












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54007806%2fincluding-a-bat-with-arguments-that-launchs-a-cmd-window-and-adds-commands-to-t%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54007806%2fincluding-a-bat-with-arguments-that-launchs-a-cmd-window-and-adds-commands-to-t%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

android studio warns about leanback feature tag usage required on manifest while using Unity exported app?

SQL update select statement

'app-layout' is not a known element: how to share Component with different Modules