Nathan Klayko
Nathan Klayko

Reputation: 125

VBSscript error - Create shortcut to FTP with username and passowrd

I have a vbsscript that I can deploy to users that will create a shortcut to an FTP drive on the user's desktop. This script works in this form:

Set objShell=Wscript.CreateObject("Wscript.shell")
strDesktopFolder=objShell.SpecialFolders("Desktop") & "\"
Set objShortcut=objShell.CreateShortcut(strDesktopFolder & "FTP.lnk")
objShortCut.TargetPath = "ftp://ftp.website.com"
objShortCut.Description = "FTP"
objShortCut.Save

This is great, but it requires that the user type a username and password to access the folder. I really need to save the username and password before as part of the deployment and eliminate extra steps for the end-user. Therefore, I want to save the username and password as part of the vbs script when I deploy it. I have come close and can save a username and password with the following:

Set objShell=Wscript.CreateObject("Wscript.shell")
strDesktopFolder=objShell.SpecialFolders("Desktop") & "\"
Set objShortcut=objShell.CreateShortcut(strDesktopFolder & "FTP.lnk")
objShortCut.TargetPath = "ftp://user:[email protected]"
objShortCut.Description = "FTP"
objShortCut.Save

However, the issue is that I can't save them correctly. The username format is:

[email protected]

This is the format for my ftp site. I cannot change that. This format returns an error (800A0005). I need my script to work without error like this:

Set objShell=Wscript.CreateObject("Wscript.shell")
strDesktopFolder=objShell.SpecialFolders("Desktop") & "\"
Set objShortcut=objShell.CreateShortcut(strDesktopFolder & "FTP.lnk")
objShortCut.TargetPath = "ftp://[email protected]:[email protected]"
objShortCut.Description = "FTP"
objShortCut.Save

Thanks for any and all help!

Upvotes: 2

Views: 433

Answers (1)

Hackoo
Hackoo

Reputation: 18827

If your username contains the @ symbol, and your web browser or the windows explorer does not like it, you must substitute it with the + symbol like this :

[email protected] = user+website.com

Set objShell=Wscript.CreateObject("Wscript.shell")
strDesktopFolder=objShell.SpecialFolders("Desktop") & "\"
Set objShortcut=objShell.CreateShortcut(strDesktopFolder & "FTP.lnk")
objShortCut.TargetPath = "ftp://user+website.com:[email protected]"
objShortCut.Description = "FTP"
objShortCut.Save

Upvotes: 2

Related Questions