How to not change title with WinSCP in batch file
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
add a comment |
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
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
add a comment |
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
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
batch-file winscp
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
add a comment |
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
add a comment |
1 Answer
1
active
oldest
votes
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
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 thels
command to get a list of file names without downloading all the files. Is there a way to runwinscp.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 Microsoftmsxsl
(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
|
show 12 more comments
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
});
}
});
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%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
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
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 thels
command to get a list of file names without downloading all the files. Is there a way to runwinscp.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 Microsoftmsxsl
(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
|
show 12 more comments
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
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 thels
command to get a list of file names without downloading all the files. Is there a way to runwinscp.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 Microsoftmsxsl
(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
|
show 12 more comments
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
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
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 thels
command to get a list of file names without downloading all the files. Is there a way to runwinscp.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 Microsoftmsxsl
(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
|
show 12 more comments
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 thels
command to get a list of file names without downloading all the files. Is there a way to runwinscp.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 Microsoftmsxsl
(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
|
show 12 more comments
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.
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%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
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
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