Differences
This shows you the differences between the selected revisions of the page.
ui_generateurl 2019-05-04 | ui_generateurl 2024-12-10 (current) | ||
Line 4: | Line 4: | ||
To open the dialog to generate the session %%URL%% or code, use: | To open the dialog to generate the session %%URL%% or code, use: | ||
- | * //Session > Generate Session %%URL%%/Code// command on the main window to generate session %%URL%% or code template for the current session. (preferred) | + | * //Tabs > Generate Session %%URL%%/Code// command on the main window to generate session %%URL%% or code template for the current session. (preferred) |
* //Manage > Generate Session %%URL/Code%%// command on the [[ui_login|Login dialog]] to generate session %%URL%% or code template for the selected site. | * //Manage > Generate Session %%URL/Code%%// command on the [[ui_login|Login dialog]] to generate session %%URL%% or code template for the selected site. | ||
- | To open the dialog to generate a file transfer code, use: | + | To open the dialog to generate a file ==transfer== code, use: |
* //Transfer Settings > Generate Code// command on the [[ui_copy|Transfer Options dialog]]. | * //Transfer Settings > Generate Code// command on the [[ui_copy|Transfer Options dialog]]. | ||
Line 13: | Line 13: | ||
To open the dialog to generate the file %%URL%%, use: | To open the dialog to generate the file %%URL%%, use: | ||
- | * //File(s) > File Names > Generate File %%URL%%// command on main window to generate file %%URL%% for files selected in the remote [[ui_file_panel|file panel]]. | + | * //Files > File Names > Generate File %%URL%%// command on main window to generate file %%URL%% for files selected in the remote [[ui_file_panel|file panel]]. |
&toc_title(The dialog has three tabs. Each is described individually.) | &toc_title(The dialog has three tabs. Each is described individually.) | ||
Line 59: | Line 59: | ||
* //Batch file// -- Generates a Windows batch file (''.bat'') template that executes the ''[[executables|winscp.com]]'' with the above commands, specified using the ''[[commandline#scripting|/command]]'' command-line switch. Additionally the batch file enables [[logging|session logging]] using the ''[[commandline#logging|/log]]'' switch and [[scripting#configuration|isolates the script run from a GUI configuration]] using the ''[[commandline#configuration|/ini=nul]]'' switch. At the end, the batch file [[scripting#result|checks WinSCP exit code]] to choose further actions to take; and propagates the WinSCP exit code to a batch file exit code using the ''exit /b'' command. //Make sure you keep the exact format of the multi-line ''winscp.com'' command, as [[faq_batch_file|multi-line batch file commands are fragile]].// | * //Batch file// -- Generates a Windows batch file (''.bat'') template that executes the ''[[executables|winscp.com]]'' with the above commands, specified using the ''[[commandline#scripting|/command]]'' command-line switch. Additionally the batch file enables [[logging|session logging]] using the ''[[commandline#logging|/log]]'' switch and [[scripting#configuration|isolates the script run from a GUI configuration]] using the ''[[commandline#configuration|/ini=nul]]'' switch. At the end, the batch file [[scripting#result|checks WinSCP exit code]] to choose further actions to take; and propagates the WinSCP exit code to a batch file exit code using the ''exit /b'' command. //Make sure you keep the exact format of the multi-line ''winscp.com'' command, as [[faq_batch_file|multi-line batch file commands are fragile]].// | ||
* //Command-line// -- Generates a command-line for the ''[[executables|winscp.exe]]'' (but usable for ''winscp.com'' too) with the above commands, session logging and configuration isolation (see the previous point). The command-line is suitable for task managers of all kinds, like [[guide_schedule|Windows Scheduler]] or [[guide_ssis|SSIS]]. Depending on your requirements, you may want prepend the ''[[commandline#scripting|/console]]'' switch to make the script console visible, while the script is running. | * //Command-line// -- Generates a command-line for the ''[[executables|winscp.exe]]'' (but usable for ''winscp.com'' too) with the above commands, session logging and configuration isolation (see the previous point). The command-line is suitable for task managers of all kinds, like [[guide_schedule|Windows Scheduler]] or [[guide_ssis|SSIS]]. Depending on your requirements, you may want prepend the ''[[commandline#scripting|/console]]'' switch to make the script console visible, while the script is running. | ||
- | * //PowerShell script// -- Generates a PowerShell script file (''.ps1'') template that executes the ''[[executables|winscp.com]]'' with the above commands, specified using the ''[[commandline#scripting|/command]]'' command-line switch. Additionally the script file enables [[logging|session logging]] using the ''[[commandline#logging|/log]]'' switch and [[scripting#configuration|isolates the script run from a GUI configuration]] using the ''[[commandline#configuration|/ini=nul]]'' switch. At the end, the script file [[scripting#result|checks WinSCP exit code]] to choose further actions to take; and propagates the WinSCP exit code to a script exit code using the [[ps>microsoft.powershell.core/about/about_language_keywords#exit|''exit'' keyword]]. //Instead of running ''winscp.com'', consider [[library_powershell|using WinSCP .NET assembly in PowerShell]].// | + | * //PowerShell script// -- Generates a PowerShell script file (''.ps1'') template that executes the ''[[executables|winscp.com]]'' with the above commands, specified using the ''[[commandline#scripting|/command]]'' command-line switch. Additionally the script file enables [[logging|session logging]] using the ''[[commandline#logging|/log]]'' switch and [[scripting#configuration|isolates the script run from a GUI configuration]] using the ''[[commandline#configuration|/ini=nul]]'' switch. At the end, the script file [[scripting#result|checks WinSCP exit code]] to choose further actions to take; and propagates the WinSCP exit code to a script exit code using the [[ps>microsoft.powershell.core/about/about_language_keywords#exit|''exit'' keyword]]. The script additionally sets [[ps>microsoft.powershell.core/about/about_preference_variables#psnativecommandargumentpassing|''$PSNativeCommandArgumentPassing'']] to ''"Legacy"'', what is needed for PowerShell 7.3 and newer to be able to pass the arguments properly to WinSCP.((You may want to reset the ''$PSNativeCommandArgumentPassing'' back to default ''"Windows"'' value after running WinSCP.)) //Instead of running ''winscp.com'', consider [[library_powershell|*]].// |
In the //Command-line// (and possibly also in the //Batch file//), you should modify a path to [[logging|a session log file]] in the ''[[commandline#logging|/log]]'' switch. | In the //Command-line// (and possibly also in the //Batch file//), you should modify a path to [[logging|a session log file]] in the ''[[commandline#logging|/log]]'' switch. | ||
Line 89: | Line 89: | ||
You can click on classes, methods and properties to open their respective help pages. | You can click on classes, methods and properties to open their respective help pages. | ||
- | @echo off | + | ===== Copying Generated URL or Code to Clipboard ===== |
- | "C:\Program Files (x86)\WinSCP\WinSCP.com" ^ | + | Use //Copy to Clipboard// to copy generated %%URL%%(s) or code to a clipboard. |
- | ··/log="C:\writable\path\to\log\WinSCP.log" /ini=nul ^ | + | |
- | /command ^ | + | |
- | "open s3://AKIAJ4MP6WJZW5BDHAEQ:Fzx9UPFUWUTxxiPIlFJdMG7WMlAqaWhicFTXvXSH@s3.amazonaws.com/" ^ | + | |
- | ····"Your command 1" ^ | + | |
- | "Your command 2" ^ | + | |
- | "exit" | + | |
- | set WINSCP_RESULT=%ERRORLEVEL% | + | ===== Limitations ===== |
- | if %WINSCP_RESULT% equ 0 ( | + | WinSCP GUI cannot be aware of path limitations of your server. So even if your server requires you to start in a specific folder, WinSCP will not generate a code that will start in that folder. You need to add that manually. //See [[faq_root_path|*]]// |
- | echo Success | + | |
- | ) else ( | + | |
- | echo Error | + | |
- | ) | + | |
- | + | ||
- | exit /b %WINSCP_RESULT% | + |