Differences
This shows you the differences between the selected revisions of the page.
2009-04-17 | 2009-04-17 | ||
syntax (martin) | wscript (martin) | ||
Line 6: | Line 6: | ||
Use language of your preference. If you have no preference or do not know any scripting language, the easiest may be to use scripting engines available in Windows: | Use language of your preference. If you have no preference or do not know any scripting language, the easiest may be to use scripting engines available in Windows: | ||
* Windows command interpreter (''cmd.exe'') to run ''.bat'' or ''.cmd'' files (for simple tasks); | * Windows command interpreter (''cmd.exe'') to run ''.bat'' or ''.cmd'' files (for simple tasks); | ||
- | * Windows script host (''cscript.exe'') to run Java Script or VB Script files. | + | * Windows script host (''[[http://technet.microsoft.com/en-us/library/bb490887.aspx|cscript.exe]]'' or ''[[http://technet.microsoft.com/en-us/library/bb490816.aspx|wscript.exe]]'') to run Java Script or VB Script files. |
===== Windows command interpreter (batch files) ===== | ===== Windows command interpreter (batch files) ===== | ||
Line 22: | Line 22: | ||
It supports all the features listed in Windows command interpreter section above (with grater flexibility). Plus it includes many advanced functions, you may find useful when using together with WinSCP. See sections below. | It supports all the features listed in Windows command interpreter section above (with grater flexibility). Plus it includes many advanced functions, you may find useful when using together with WinSCP. See sections below. | ||
- | To use the examples below copy the JavaScript code to file (e.g. ''example.js'') and use ''cscript.exe'' to execute it (use ''/nologo'' to suppress banner): | + | To use the examples below copy the JavaScript code to file (e.g. ''example.js'') and use ''[[http://technet.microsoft.com/en-us/library/bb490887.aspx|cscript.exe]]'' to execute it (use ''/nologo'' to suppress banner): |
<code> | <code> | ||
cscript /nologo example.js | cscript /nologo example.js | ||
Line 98: | Line 98: | ||
faq_filemanager.txt | faq_filemanager.txt | ||
</code> | </code> | ||
+ | |||
+ | ==== Hidden execution ==== | ||
+ | When executing JavaScript code with ''[[http://technet.microsoft.com/en-us/library/bb490887.aspx|cscript.exe]]'', console window is shown. If you want to execute the JavaScript without showing console window, use ''[[http://technet.microsoft.com/en-us/library/bb490816.aspx|wscript.exe]]'' instead. | ||
+ | |||
+ | Some notes for using ''wscript'': | ||
+ | * Every call to ''WScript.Echo'' causes message box to be shown, pausing the execution. So generaly you do not want to use ''WScript.Echo'' from ''wscript.exe''. | ||
+ | * Execution of ''winscp.com'' opens new console window (if one is not opened already, e.g. by ''cscript.exe''). Use ''winscp.exe'' instead (without ''/console'' switch). However ''winscp.exe'' does not allow input/output redirection, so you need to pass the commands in [[scripting#using_scripting|using command-line]]. | ||
===== External script interpreters (PHP, Perl, etc) ===== | ===== External script interpreters (PHP, Perl, etc) ===== |