running batch files from C# takes too much time
I am running a batch file from c# align.bat it is taking more than 40 seconds
but when i run the same batch file manually it takes less than 2 seconds. what changes is needed to eliminate the extra time consumed?
string comnd = Directory.GetCurrentDirectory();
Process batchProcess = new Process();
batchProcess.StartInfo.FileName = comnd + Path.DirectorySeparatorChar + "align.bat";
batchProcess.StartInfo.WorkingDirectory = comnd;
//batchProcess.StartInfo.RedirectStandardOutput = true;
batchProcess.Start();
batchProcess.WaitForExit();
c# batch-file cmd
|
show 14 more comments
I am running a batch file from c# align.bat it is taking more than 40 seconds
but when i run the same batch file manually it takes less than 2 seconds. what changes is needed to eliminate the extra time consumed?
string comnd = Directory.GetCurrentDirectory();
Process batchProcess = new Process();
batchProcess.StartInfo.FileName = comnd + Path.DirectorySeparatorChar + "align.bat";
batchProcess.StartInfo.WorkingDirectory = comnd;
//batchProcess.StartInfo.RedirectStandardOutput = true;
batchProcess.Start();
batchProcess.WaitForExit();
c# batch-file cmd
instead of executing bat. you can execute cmd and give string content of batch file as CMD parameters. so it will be running same as bat file. can you try it ?
– Halil İbrahim
Nov 23 '18 at 7:40
This should not happen. Something else than the code you show must be the reason..
– TaW
Nov 23 '18 at 7:41
1
well, what does the batch file do? how about posting its code?
– Gerhard Barnard
Nov 23 '18 at 7:41
2
Why would you usePath.DirectorySeparatorChar
and then manually combine paths whenPath
already has methods for doing that?
– Damien_The_Unbeliever
Nov 23 '18 at 7:47
@GerhardBarnard "...when i run the same batch filemanually
it takes less than2 seconds
"
– MickyD
Nov 23 '18 at 7:53
|
show 14 more comments
I am running a batch file from c# align.bat it is taking more than 40 seconds
but when i run the same batch file manually it takes less than 2 seconds. what changes is needed to eliminate the extra time consumed?
string comnd = Directory.GetCurrentDirectory();
Process batchProcess = new Process();
batchProcess.StartInfo.FileName = comnd + Path.DirectorySeparatorChar + "align.bat";
batchProcess.StartInfo.WorkingDirectory = comnd;
//batchProcess.StartInfo.RedirectStandardOutput = true;
batchProcess.Start();
batchProcess.WaitForExit();
c# batch-file cmd
I am running a batch file from c# align.bat it is taking more than 40 seconds
but when i run the same batch file manually it takes less than 2 seconds. what changes is needed to eliminate the extra time consumed?
string comnd = Directory.GetCurrentDirectory();
Process batchProcess = new Process();
batchProcess.StartInfo.FileName = comnd + Path.DirectorySeparatorChar + "align.bat";
batchProcess.StartInfo.WorkingDirectory = comnd;
//batchProcess.StartInfo.RedirectStandardOutput = true;
batchProcess.Start();
batchProcess.WaitForExit();
c# batch-file cmd
c# batch-file cmd
asked Nov 23 '18 at 7:38
Lakshmi Tejas M ALakshmi Tejas M A
113
113
instead of executing bat. you can execute cmd and give string content of batch file as CMD parameters. so it will be running same as bat file. can you try it ?
– Halil İbrahim
Nov 23 '18 at 7:40
This should not happen. Something else than the code you show must be the reason..
– TaW
Nov 23 '18 at 7:41
1
well, what does the batch file do? how about posting its code?
– Gerhard Barnard
Nov 23 '18 at 7:41
2
Why would you usePath.DirectorySeparatorChar
and then manually combine paths whenPath
already has methods for doing that?
– Damien_The_Unbeliever
Nov 23 '18 at 7:47
@GerhardBarnard "...when i run the same batch filemanually
it takes less than2 seconds
"
– MickyD
Nov 23 '18 at 7:53
|
show 14 more comments
instead of executing bat. you can execute cmd and give string content of batch file as CMD parameters. so it will be running same as bat file. can you try it ?
– Halil İbrahim
Nov 23 '18 at 7:40
This should not happen. Something else than the code you show must be the reason..
– TaW
Nov 23 '18 at 7:41
1
well, what does the batch file do? how about posting its code?
– Gerhard Barnard
Nov 23 '18 at 7:41
2
Why would you usePath.DirectorySeparatorChar
and then manually combine paths whenPath
already has methods for doing that?
– Damien_The_Unbeliever
Nov 23 '18 at 7:47
@GerhardBarnard "...when i run the same batch filemanually
it takes less than2 seconds
"
– MickyD
Nov 23 '18 at 7:53
instead of executing bat. you can execute cmd and give string content of batch file as CMD parameters. so it will be running same as bat file. can you try it ?
– Halil İbrahim
Nov 23 '18 at 7:40
instead of executing bat. you can execute cmd and give string content of batch file as CMD parameters. so it will be running same as bat file. can you try it ?
– Halil İbrahim
Nov 23 '18 at 7:40
This should not happen. Something else than the code you show must be the reason..
– TaW
Nov 23 '18 at 7:41
This should not happen. Something else than the code you show must be the reason..
– TaW
Nov 23 '18 at 7:41
1
1
well, what does the batch file do? how about posting its code?
– Gerhard Barnard
Nov 23 '18 at 7:41
well, what does the batch file do? how about posting its code?
– Gerhard Barnard
Nov 23 '18 at 7:41
2
2
Why would you use
Path.DirectorySeparatorChar
and then manually combine paths when Path
already has methods for doing that?– Damien_The_Unbeliever
Nov 23 '18 at 7:47
Why would you use
Path.DirectorySeparatorChar
and then manually combine paths when Path
already has methods for doing that?– Damien_The_Unbeliever
Nov 23 '18 at 7:47
@GerhardBarnard "...when i run the same batch file
manually
it takes less than 2 seconds
"– MickyD
Nov 23 '18 at 7:53
@GerhardBarnard "...when i run the same batch file
manually
it takes less than 2 seconds
"– MickyD
Nov 23 '18 at 7:53
|
show 14 more comments
1 Answer
1
active
oldest
votes
Testing revealed that the issue was caused by an anti-malware software suite installed on all of employer's computers.
This software probably detects a new piece of software as an unknown dropper and at first runs anything it starts silently in a sandbox before starting it normally.
Solution should then be to whitelist the program(s) causing issues and/or disable sandboxing.
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53442454%2frunning-batch-files-from-c-sharp-takes-too-much-time%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Testing revealed that the issue was caused by an anti-malware software suite installed on all of employer's computers.
This software probably detects a new piece of software as an unknown dropper and at first runs anything it starts silently in a sandbox before starting it normally.
Solution should then be to whitelist the program(s) causing issues and/or disable sandboxing.
add a comment |
Testing revealed that the issue was caused by an anti-malware software suite installed on all of employer's computers.
This software probably detects a new piece of software as an unknown dropper and at first runs anything it starts silently in a sandbox before starting it normally.
Solution should then be to whitelist the program(s) causing issues and/or disable sandboxing.
add a comment |
Testing revealed that the issue was caused by an anti-malware software suite installed on all of employer's computers.
This software probably detects a new piece of software as an unknown dropper and at first runs anything it starts silently in a sandbox before starting it normally.
Solution should then be to whitelist the program(s) causing issues and/or disable sandboxing.
Testing revealed that the issue was caused by an anti-malware software suite installed on all of employer's computers.
This software probably detects a new piece of software as an unknown dropper and at first runs anything it starts silently in a sandbox before starting it normally.
Solution should then be to whitelist the program(s) causing issues and/or disable sandboxing.
answered Dec 5 '18 at 23:15
Jack WhiteJack White
33416
33416
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53442454%2frunning-batch-files-from-c-sharp-takes-too-much-time%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
instead of executing bat. you can execute cmd and give string content of batch file as CMD parameters. so it will be running same as bat file. can you try it ?
– Halil İbrahim
Nov 23 '18 at 7:40
This should not happen. Something else than the code you show must be the reason..
– TaW
Nov 23 '18 at 7:41
1
well, what does the batch file do? how about posting its code?
– Gerhard Barnard
Nov 23 '18 at 7:41
2
Why would you use
Path.DirectorySeparatorChar
and then manually combine paths whenPath
already has methods for doing that?– Damien_The_Unbeliever
Nov 23 '18 at 7:47
@GerhardBarnard "...when i run the same batch file
manually
it takes less than2 seconds
"– MickyD
Nov 23 '18 at 7:53