如何通过 VBScript 在 Windows 中打开 FTP 文件夹 [英] How to open an FTP folder in Windows via VBScript
问题描述
到目前为止我的代码:
Set oShell = CreateObject("Shell.Application")
Set objFSO = CreateObject("Scripting.FileSystemObject")
set objShell = CreateObject("WScript.Shell")
'Copy Options: 16 = Yes to All
Const copyType = 16
'FTP Wait Time in ms
waitTime = 80000
FTPUser = "myuser"
FTPPass = "mypass"
FTPHost = "ftp IP"
FTPDir = "/Creative/"
strFTP = "ftp://" & FTPUser & "+" & FTPPass & "@" & FTPHost & FTPDir
Set objFTP = oShell.NameSpace(strFTP)
我可以连接到我的 FTP 文件夹,现在我需要在 Windows 资源管理器中打开该文件夹.
I am able to connect to my FTP folder, now I need to open that folder in Windows explorer.
推荐答案
你可以这样试试:
set objShell = CreateObject("WScript.Shell")
Login = "Your Username"
'If your username contains the @ symbol, and your web browser does not support this, you can substitute for the +
Login = Replace(Login,"@","+")
Password = "Your Pass"
FTPSERVER = "ftp.server.com"
RemoteFolder = "RemoteFolderName"
FTPURL = "ftp://"& Login &":"& Password &"@"& FTPSERVER &"/"& RemoteFolder
Connect2FTP = objShell.run("Explorer "& FTPURL ,1,False)
我已经做了一个旧的 vbscript 来处理这样的事情
I have done an old vbscript to deal like that
描述:
你和朋友在不同的电脑上还是在网吧里?您要添加、修改、删除 FTP 服务器上的文件或文件夹吗?没有机会,您手头没有程序作为 FTP 客户端(如 FileZilla、CuteFTP、FlashFXP 等...)来访问您的私人 FTP 服务器!没问题 => FTP Explorer 是在您的 FTP 客户端中打开您的网络浏览器或 Windows 资源管理器的解决方案!
You are on a different computer than you, either with friends or in a cybercafe? You want to add, modify, delete files or folders on your FTP server? No chance, you do not have programs on hand as FTP clients like (FileZilla, CuteFTP, FlashFXP. Etc ...) to access your Private FTP server ! No problem => FTP Explorer is the solution to turn your web browser or windows explorer in your FTP client !
我只是将这个旧的法语版本翻译成英语版本!
I'd just translate this old french version to english version !
希望能帮到你!
Titre = "FTP EXPLORER © Hackoo © 2016"
Set objIE = CreateObject( "InternetExplorer.Application" )
objIE.Navigate "about:blank"
objIE.Document.Title = Titre
objIE.ToolBar = False
objIE.Resizable = False
objIE.StatusBar = False
objIE.Width = 320
objIE.Height = 390
ScreenWidth = objIE.document.ParentWindow.screen.width
ScreenHeight = objIE.document.ParentWindow.screen.height
objIE.Left = (ScreenWidth - objIE.Width ) 2
objIE.Top = (ScreenHeight - objIE.Height) 2
Do While objIE.Busy
WScript.Sleep 200
Loop
objIE.Document.Body.InnerHTML = "<div align=""center""><p><h3 style='color:Red'>UserName " _
& "<br><input type=""text"" style='color:Blue' size=""20"" " _
& "id=""Login"" value=""put your user name here""></h3></p>"_
& "</p><p><h3 style='color:Red'>Password<br><input type=""password"" style='color:Blue' value=""Put your password here"" size=""20"" " _
& "id=""Password""></h3></p><p><input type=" _
& """hidden"" id=""OK"" name=""OK"" value=""0"">" _
& "<h3 style='color:Red'>FTP Server " _
& "<br><input type=""text"" style='color:Blue' size=""20"" " _
& "id=""FTPSERVER"" value=""ftp.server.com""></h3>"_
& "<br><h3 style='color:Red'>Remote Folder "_
& "<br><input type=""text"" style='color:Blue' size=""20"" " _
& "id=""DossierDistant"" value=""/www""></h3></p>"_
& "<input type=""submit"" value="" Browse your FTP Folder"" " _
& "onclick=""VBScript:OK.Value=1""></p></div>"
objIE.Document.Body.Style.overflow = "auto"
objIE.Document.body.style.backgroundcolor="lightGreen"
objIE.Visible = True
objIE.Document.All.Password.Focus
On Error Resume Next
Do While objIE.Document.All.OK.Value = 0
WScript.Sleep 200
If Err Then
IELogin = Array( "", "" )
objIE.Quit
Set objIE = Nothing
wscript.quit
End if
Loop
On Error Goto 0
Set ws = CreateObject("wscript.Shell")
Login = objIE.Document.All.Login.Value
Login = Replace(Login,"@","+")'If your username contains the @ symbol, and your web browser does not support this, you can substitute for the +
Password = objIE.Document.All.Password.Value
FTPSERVER = objIE.Document.All.FTPSERVER.Value
DossierDistant = objIE.Document.All.DossierDistant.Value
URL = "ftp://"&Login&":"&Password&"@"&FTPSERVER&"/"&DossierDistant
Connect2FTP = ws.run("Explorer "& URL ,1,False)
objIE.Quit
ws.Popup "Connecting to "&qq(FTPSERVER)&" is in progress ..........",3,"Connecting to "&qq(FTPSERVER)&" is in progress ..........",64
Set objIE = Nothing
Set ws = Nothing
Close("iexplore.exe")
'****************************************************
Sub Close(Process)
Set Ws = CreateObject("Wscript.Shell")
Command = "cmd /c Taskkill /F /IM "&Process&""
Execution = Ws.Run(Command,0,True)
End Sub
'****************************************************
Function qq(strIn)
qq = Chr(34) & strIn & Chr(34)
End Function
'****************************************************
这篇关于如何通过 VBScript 在 Windows 中打开 FTP 文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!