我正在尝试寻找一个脚本,它可以让我在XP (或7)中右击一个文件,然后选择和选项(如"Copy to MyServer")。
这会将文件复制到设置的位置,然后将文件路径和文件名复制到剪贴板,这样我就可以将该位置粘贴到其他位置。(我想将其粘贴到我的服务台票证中,该票证只接受图片的URL。)
因此,基本上这将允许我将计算机上的图片复制到特定的服务器,然后将该位置粘贴到我的表单中。讲得通?
我找到了一些可以复制文件的VBS代码,还有一些可以让我右击文件以显示位置的VBS代码。但我不知道如何将它们结合起来。你有什么建议吗?
复制代码:
Dim FSO
Set FSO = CreateObject("Scripting.FileSystemObject")
FSO.CopyFile "\\file to be copied path", "\\destination directory"获取路径代码(需要对注册表进行编辑才能在上下文菜单中显示):
set oFso = createObject("scripting.filesystemobject")
if wscript.arguments.count >= 1 then
strPath = wscript.arguments(0)
strDriveName = ofso.GetDriveName(strPath)
set oDrive = ofso.GetDrive(strDriveName)
Select Case oDrive.DriveType
Case 0: t = "Unknown"
Case 1: t = "Removable"
Case 2: t = "Fixed"
Case 3: t = "Network"
Case 4: t = "CD-ROM"
Case 5: t = "RAM Disk"
End Select
strFileName = ofso.GetFileName(strPath)
test = inputbox("The path is...","Path", strPath)
else
msgbox "no args"
end if发布于 2011-12-07 06:38:42
这段代码将接受一个参数(文件名),并将其移动到代码顶部sLocation中定义的位置。一旦完成,它将显示一个确认,并将文件的路径(在新位置)放在剪贴板中进行粘贴。
据我所知,VBScript没有直接操作剪贴板的能力,所以我们把这个交给MSDOS clip命令来完成。
Option Explicit
' Change sLocation in the line below to the folder you want to move files to.
Dim sLocation : sLocation = "C:\Temp"
Dim fso : Set fso = CreateObject("Scripting.FileSystemObject")
Dim wsh : Set wsh = WScript.CreateObject("WScript.Shell")
If WScript.Arguments.Count = 0 Then
MsgBox "Missing a filename!"
WScript.Quit
End If
If fso.FileExists(WScript.Arguments(0)) = False Then
MsgBox "File '" & WScript.Arguments(0) & "' doesn't exist!"
WScript.Quit
End If
Dim oFile : Set oFile = fso.GetFile(WScript.Arguments(0))
fso.CopyFile oFile.Path, sLocation
Dim sNewLocation : sNewLocation = sLocation & "\" & oFile.Name
wsh.Run "cmd.exe /c echo " & sNewLocation & "| clip", 0, True
Msgbox "File moved to " & sNewLocation & VbCrLf & "and new path copied to clipboard."
Set fso = Nothing
Set wsh = Nothing
Set oFile = Nothing要安装,您需要添加一个注册表项,以便在右键单击某个项目时调用此脚本,或者您运行以下命令shell:sendto以打开“发送到”文件夹,并在此处放置脚本的快捷方式。如果你选择后者,那么你应该能够右击一个文件并从"Send To“菜单中选择脚本。
https://stackoverflow.com/questions/6378398
复制相似问题