How to not change title with WinSCP in batch file












1














I'm using WinSCP in my batch file (the portable version) to download FTP files, however, whenever I run it from a batch file it changes the window title. Is there any way I can avoid that?



My complete script is here on github



But to summarize my use of WinSCP, it basically generates a temporary script file, executes it with winscp.com, redirects its output to another temporary file and parses the output for some keywords.



An example of execution:



WinSCP.com /open /script=t.ftp /ini=nul ftp://%ftpusr%:%ftppass%@%server% >test.ftp









share|improve this question
























  • It’s a chat program. An assignment.
    – Mark Deven
    Dec 21 '18 at 16:42










  • Just it changes the title. I handle the output.
    – Mark Deven
    Dec 21 '18 at 16:42










  • You can look at it and see...
    – Mark Deven
    Dec 21 '18 at 16:43
















1














I'm using WinSCP in my batch file (the portable version) to download FTP files, however, whenever I run it from a batch file it changes the window title. Is there any way I can avoid that?



My complete script is here on github



But to summarize my use of WinSCP, it basically generates a temporary script file, executes it with winscp.com, redirects its output to another temporary file and parses the output for some keywords.



An example of execution:



WinSCP.com /open /script=t.ftp /ini=nul ftp://%ftpusr%:%ftppass%@%server% >test.ftp









share|improve this question
























  • It’s a chat program. An assignment.
    – Mark Deven
    Dec 21 '18 at 16:42










  • Just it changes the title. I handle the output.
    – Mark Deven
    Dec 21 '18 at 16:42










  • You can look at it and see...
    – Mark Deven
    Dec 21 '18 at 16:43














1












1








1


2





I'm using WinSCP in my batch file (the portable version) to download FTP files, however, whenever I run it from a batch file it changes the window title. Is there any way I can avoid that?



My complete script is here on github



But to summarize my use of WinSCP, it basically generates a temporary script file, executes it with winscp.com, redirects its output to another temporary file and parses the output for some keywords.



An example of execution:



WinSCP.com /open /script=t.ftp /ini=nul ftp://%ftpusr%:%ftppass%@%server% >test.ftp









share|improve this question















I'm using WinSCP in my batch file (the portable version) to download FTP files, however, whenever I run it from a batch file it changes the window title. Is there any way I can avoid that?



My complete script is here on github



But to summarize my use of WinSCP, it basically generates a temporary script file, executes it with winscp.com, redirects its output to another temporary file and parses the output for some keywords.



An example of execution:



WinSCP.com /open /script=t.ftp /ini=nul ftp://%ftpusr%:%ftppass%@%server% >test.ftp






batch-file winscp






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 21 '18 at 17:02









Martin Prikryl

10.8k43276




10.8k43276










asked Dec 21 '18 at 15:27









Mark Deven

520120




520120












  • It’s a chat program. An assignment.
    – Mark Deven
    Dec 21 '18 at 16:42










  • Just it changes the title. I handle the output.
    – Mark Deven
    Dec 21 '18 at 16:42










  • You can look at it and see...
    – Mark Deven
    Dec 21 '18 at 16:43


















  • It’s a chat program. An assignment.
    – Mark Deven
    Dec 21 '18 at 16:42










  • Just it changes the title. I handle the output.
    – Mark Deven
    Dec 21 '18 at 16:42










  • You can look at it and see...
    – Mark Deven
    Dec 21 '18 at 16:43
















It’s a chat program. An assignment.
– Mark Deven
Dec 21 '18 at 16:42




It’s a chat program. An assignment.
– Mark Deven
Dec 21 '18 at 16:42












Just it changes the title. I handle the output.
– Mark Deven
Dec 21 '18 at 16:42




Just it changes the title. I handle the output.
– Mark Deven
Dec 21 '18 at 16:42












You can look at it and see...
– Mark Deven
Dec 21 '18 at 16:43




You can look at it and see...
– Mark Deven
Dec 21 '18 at 16:43










1 Answer
1






active

oldest

votes


















2














No you cannot prevent winscp.com from changing console window title.





Note that a console window title is changed by winscp.com only, whose sole purpose is that it is a console application. As a console application, it inherits a console of the parent console application (if any), like that of cmd.exe, when executed from a batch file. Then it can write its output to it, instead of opening a separate console window, what would otherwise equivalent winscp.exe /console call do (winscp.exe is GUI application, so it cannot inherit a console window of parent process). Read about WinSCP executables.



But you seem to want to prevent users from seeing the output of winscp.com too. You only abuse the (hidden) output for error checking. That's not a very reliable approach. You better use WinSCP exit code to check for errors. See How do I know that script completed successfully? If you need even more detailed error checking, you can use XML logging.



Once you get rid of your abuse of WinSCP output, you can switch to winscp.exe with the same arguments. When winscp.exe is called with /command switch, but without /console switch, it runs the commands completely silently (and it does not change console title).



Though for such a complicated use, you should switch from plain WinSCP scripting to WinSCP .NET assembly and PowerShell. Your code will be way cleaner and more robust.





For a quick solution, you can run winscp.com in its own hidden console.

See Run a batch file in a completely hidden way.

(though contrary to most examples, you want to set the bWaitOnReturn argument to True).



You need your batch file to generate a .vbs script like this:



Set oShell = CreateObject ("Wscript.Shell") 
Dim strArgs
strArgs = "cmd.exe /c ""C:somepathwinscp.com"" /ini=nul /script=temp.ftp ftp://username:password@host > output.txt"
oShell.Run strArgs, 0, true


And then run it from the batch file like:



cscript runwinscp.vbs





share|improve this answer























  • Well I handle individually the output of many of the commands. For instance, with file sharing section of my code (:fileman), I handle the results of the ls command to get a list of file names without downloading all the files. Is there a way to run winscp.exe /command and send output to a text file?
    – Mark Deven
    Dec 21 '18 at 18:34












  • No. You should not parse WinSCP output anyway. If you need detailed results, parse XML log file. There’s even example for retrieving listing fron the log - winscp.net/eng/docs/logging_xml#xslt
    – Martin Prikryl
    Dec 21 '18 at 18:38










  • There is no native xml parser in batch code though.
    – Mark Deven
    Dec 21 '18 at 18:39










  • You can download Microsoft msxsl (as you can see in the linked article) - though indeed doing such complex scripting in a batch file is not a good idea.
    – Martin Prikryl
    Dec 21 '18 at 18:41












  • I searched for something like that last year for weeks and found nothing :/. Thanks.
    – Mark Deven
    Dec 21 '18 at 18:47











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
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%2fsuperuser.com%2fquestions%2f1386688%2fhow-to-not-change-title-with-winscp-in-batch-file%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









2














No you cannot prevent winscp.com from changing console window title.





Note that a console window title is changed by winscp.com only, whose sole purpose is that it is a console application. As a console application, it inherits a console of the parent console application (if any), like that of cmd.exe, when executed from a batch file. Then it can write its output to it, instead of opening a separate console window, what would otherwise equivalent winscp.exe /console call do (winscp.exe is GUI application, so it cannot inherit a console window of parent process). Read about WinSCP executables.



But you seem to want to prevent users from seeing the output of winscp.com too. You only abuse the (hidden) output for error checking. That's not a very reliable approach. You better use WinSCP exit code to check for errors. See How do I know that script completed successfully? If you need even more detailed error checking, you can use XML logging.



Once you get rid of your abuse of WinSCP output, you can switch to winscp.exe with the same arguments. When winscp.exe is called with /command switch, but without /console switch, it runs the commands completely silently (and it does not change console title).



Though for such a complicated use, you should switch from plain WinSCP scripting to WinSCP .NET assembly and PowerShell. Your code will be way cleaner and more robust.





For a quick solution, you can run winscp.com in its own hidden console.

See Run a batch file in a completely hidden way.

(though contrary to most examples, you want to set the bWaitOnReturn argument to True).



You need your batch file to generate a .vbs script like this:



Set oShell = CreateObject ("Wscript.Shell") 
Dim strArgs
strArgs = "cmd.exe /c ""C:somepathwinscp.com"" /ini=nul /script=temp.ftp ftp://username:password@host > output.txt"
oShell.Run strArgs, 0, true


And then run it from the batch file like:



cscript runwinscp.vbs





share|improve this answer























  • Well I handle individually the output of many of the commands. For instance, with file sharing section of my code (:fileman), I handle the results of the ls command to get a list of file names without downloading all the files. Is there a way to run winscp.exe /command and send output to a text file?
    – Mark Deven
    Dec 21 '18 at 18:34












  • No. You should not parse WinSCP output anyway. If you need detailed results, parse XML log file. There’s even example for retrieving listing fron the log - winscp.net/eng/docs/logging_xml#xslt
    – Martin Prikryl
    Dec 21 '18 at 18:38










  • There is no native xml parser in batch code though.
    – Mark Deven
    Dec 21 '18 at 18:39










  • You can download Microsoft msxsl (as you can see in the linked article) - though indeed doing such complex scripting in a batch file is not a good idea.
    – Martin Prikryl
    Dec 21 '18 at 18:41












  • I searched for something like that last year for weeks and found nothing :/. Thanks.
    – Mark Deven
    Dec 21 '18 at 18:47
















2














No you cannot prevent winscp.com from changing console window title.





Note that a console window title is changed by winscp.com only, whose sole purpose is that it is a console application. As a console application, it inherits a console of the parent console application (if any), like that of cmd.exe, when executed from a batch file. Then it can write its output to it, instead of opening a separate console window, what would otherwise equivalent winscp.exe /console call do (winscp.exe is GUI application, so it cannot inherit a console window of parent process). Read about WinSCP executables.



But you seem to want to prevent users from seeing the output of winscp.com too. You only abuse the (hidden) output for error checking. That's not a very reliable approach. You better use WinSCP exit code to check for errors. See How do I know that script completed successfully? If you need even more detailed error checking, you can use XML logging.



Once you get rid of your abuse of WinSCP output, you can switch to winscp.exe with the same arguments. When winscp.exe is called with /command switch, but without /console switch, it runs the commands completely silently (and it does not change console title).



Though for such a complicated use, you should switch from plain WinSCP scripting to WinSCP .NET assembly and PowerShell. Your code will be way cleaner and more robust.





For a quick solution, you can run winscp.com in its own hidden console.

See Run a batch file in a completely hidden way.

(though contrary to most examples, you want to set the bWaitOnReturn argument to True).



You need your batch file to generate a .vbs script like this:



Set oShell = CreateObject ("Wscript.Shell") 
Dim strArgs
strArgs = "cmd.exe /c ""C:somepathwinscp.com"" /ini=nul /script=temp.ftp ftp://username:password@host > output.txt"
oShell.Run strArgs, 0, true


And then run it from the batch file like:



cscript runwinscp.vbs





share|improve this answer























  • Well I handle individually the output of many of the commands. For instance, with file sharing section of my code (:fileman), I handle the results of the ls command to get a list of file names without downloading all the files. Is there a way to run winscp.exe /command and send output to a text file?
    – Mark Deven
    Dec 21 '18 at 18:34












  • No. You should not parse WinSCP output anyway. If you need detailed results, parse XML log file. There’s even example for retrieving listing fron the log - winscp.net/eng/docs/logging_xml#xslt
    – Martin Prikryl
    Dec 21 '18 at 18:38










  • There is no native xml parser in batch code though.
    – Mark Deven
    Dec 21 '18 at 18:39










  • You can download Microsoft msxsl (as you can see in the linked article) - though indeed doing such complex scripting in a batch file is not a good idea.
    – Martin Prikryl
    Dec 21 '18 at 18:41












  • I searched for something like that last year for weeks and found nothing :/. Thanks.
    – Mark Deven
    Dec 21 '18 at 18:47














2












2








2






No you cannot prevent winscp.com from changing console window title.





Note that a console window title is changed by winscp.com only, whose sole purpose is that it is a console application. As a console application, it inherits a console of the parent console application (if any), like that of cmd.exe, when executed from a batch file. Then it can write its output to it, instead of opening a separate console window, what would otherwise equivalent winscp.exe /console call do (winscp.exe is GUI application, so it cannot inherit a console window of parent process). Read about WinSCP executables.



But you seem to want to prevent users from seeing the output of winscp.com too. You only abuse the (hidden) output for error checking. That's not a very reliable approach. You better use WinSCP exit code to check for errors. See How do I know that script completed successfully? If you need even more detailed error checking, you can use XML logging.



Once you get rid of your abuse of WinSCP output, you can switch to winscp.exe with the same arguments. When winscp.exe is called with /command switch, but without /console switch, it runs the commands completely silently (and it does not change console title).



Though for such a complicated use, you should switch from plain WinSCP scripting to WinSCP .NET assembly and PowerShell. Your code will be way cleaner and more robust.





For a quick solution, you can run winscp.com in its own hidden console.

See Run a batch file in a completely hidden way.

(though contrary to most examples, you want to set the bWaitOnReturn argument to True).



You need your batch file to generate a .vbs script like this:



Set oShell = CreateObject ("Wscript.Shell") 
Dim strArgs
strArgs = "cmd.exe /c ""C:somepathwinscp.com"" /ini=nul /script=temp.ftp ftp://username:password@host > output.txt"
oShell.Run strArgs, 0, true


And then run it from the batch file like:



cscript runwinscp.vbs





share|improve this answer














No you cannot prevent winscp.com from changing console window title.





Note that a console window title is changed by winscp.com only, whose sole purpose is that it is a console application. As a console application, it inherits a console of the parent console application (if any), like that of cmd.exe, when executed from a batch file. Then it can write its output to it, instead of opening a separate console window, what would otherwise equivalent winscp.exe /console call do (winscp.exe is GUI application, so it cannot inherit a console window of parent process). Read about WinSCP executables.



But you seem to want to prevent users from seeing the output of winscp.com too. You only abuse the (hidden) output for error checking. That's not a very reliable approach. You better use WinSCP exit code to check for errors. See How do I know that script completed successfully? If you need even more detailed error checking, you can use XML logging.



Once you get rid of your abuse of WinSCP output, you can switch to winscp.exe with the same arguments. When winscp.exe is called with /command switch, but without /console switch, it runs the commands completely silently (and it does not change console title).



Though for such a complicated use, you should switch from plain WinSCP scripting to WinSCP .NET assembly and PowerShell. Your code will be way cleaner and more robust.





For a quick solution, you can run winscp.com in its own hidden console.

See Run a batch file in a completely hidden way.

(though contrary to most examples, you want to set the bWaitOnReturn argument to True).



You need your batch file to generate a .vbs script like this:



Set oShell = CreateObject ("Wscript.Shell") 
Dim strArgs
strArgs = "cmd.exe /c ""C:somepathwinscp.com"" /ini=nul /script=temp.ftp ftp://username:password@host > output.txt"
oShell.Run strArgs, 0, true


And then run it from the batch file like:



cscript runwinscp.vbs






share|improve this answer














share|improve this answer



share|improve this answer








edited Dec 21 '18 at 20:01

























answered Dec 21 '18 at 16:59









Martin Prikryl

10.8k43276




10.8k43276












  • Well I handle individually the output of many of the commands. For instance, with file sharing section of my code (:fileman), I handle the results of the ls command to get a list of file names without downloading all the files. Is there a way to run winscp.exe /command and send output to a text file?
    – Mark Deven
    Dec 21 '18 at 18:34












  • No. You should not parse WinSCP output anyway. If you need detailed results, parse XML log file. There’s even example for retrieving listing fron the log - winscp.net/eng/docs/logging_xml#xslt
    – Martin Prikryl
    Dec 21 '18 at 18:38










  • There is no native xml parser in batch code though.
    – Mark Deven
    Dec 21 '18 at 18:39










  • You can download Microsoft msxsl (as you can see in the linked article) - though indeed doing such complex scripting in a batch file is not a good idea.
    – Martin Prikryl
    Dec 21 '18 at 18:41












  • I searched for something like that last year for weeks and found nothing :/. Thanks.
    – Mark Deven
    Dec 21 '18 at 18:47


















  • Well I handle individually the output of many of the commands. For instance, with file sharing section of my code (:fileman), I handle the results of the ls command to get a list of file names without downloading all the files. Is there a way to run winscp.exe /command and send output to a text file?
    – Mark Deven
    Dec 21 '18 at 18:34












  • No. You should not parse WinSCP output anyway. If you need detailed results, parse XML log file. There’s even example for retrieving listing fron the log - winscp.net/eng/docs/logging_xml#xslt
    – Martin Prikryl
    Dec 21 '18 at 18:38










  • There is no native xml parser in batch code though.
    – Mark Deven
    Dec 21 '18 at 18:39










  • You can download Microsoft msxsl (as you can see in the linked article) - though indeed doing such complex scripting in a batch file is not a good idea.
    – Martin Prikryl
    Dec 21 '18 at 18:41












  • I searched for something like that last year for weeks and found nothing :/. Thanks.
    – Mark Deven
    Dec 21 '18 at 18:47
















Well I handle individually the output of many of the commands. For instance, with file sharing section of my code (:fileman), I handle the results of the ls command to get a list of file names without downloading all the files. Is there a way to run winscp.exe /command and send output to a text file?
– Mark Deven
Dec 21 '18 at 18:34






Well I handle individually the output of many of the commands. For instance, with file sharing section of my code (:fileman), I handle the results of the ls command to get a list of file names without downloading all the files. Is there a way to run winscp.exe /command and send output to a text file?
– Mark Deven
Dec 21 '18 at 18:34














No. You should not parse WinSCP output anyway. If you need detailed results, parse XML log file. There’s even example for retrieving listing fron the log - winscp.net/eng/docs/logging_xml#xslt
– Martin Prikryl
Dec 21 '18 at 18:38




No. You should not parse WinSCP output anyway. If you need detailed results, parse XML log file. There’s even example for retrieving listing fron the log - winscp.net/eng/docs/logging_xml#xslt
– Martin Prikryl
Dec 21 '18 at 18:38












There is no native xml parser in batch code though.
– Mark Deven
Dec 21 '18 at 18:39




There is no native xml parser in batch code though.
– Mark Deven
Dec 21 '18 at 18:39












You can download Microsoft msxsl (as you can see in the linked article) - though indeed doing such complex scripting in a batch file is not a good idea.
– Martin Prikryl
Dec 21 '18 at 18:41






You can download Microsoft msxsl (as you can see in the linked article) - though indeed doing such complex scripting in a batch file is not a good idea.
– Martin Prikryl
Dec 21 '18 at 18:41














I searched for something like that last year for weeks and found nothing :/. Thanks.
– Mark Deven
Dec 21 '18 at 18:47




I searched for something like that last year for weeks and found nothing :/. Thanks.
– Mark Deven
Dec 21 '18 at 18:47


















draft saved

draft discarded




















































Thanks for contributing an answer to Super User!


  • 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.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • 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%2fsuperuser.com%2fquestions%2f1386688%2fhow-to-not-change-title-with-winscp-in-batch-file%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

Probability when a professor distributes a quiz and homework assignment to a class of n students.

Aardman Animations

Are they similar matrix