C:\Test>winclip -v
winclip - copy/paste the Windows clipboard. $Revision: 1.23 $
(C) Copyright 1994-2005 Diomidis D. Spinelllis. All rights reserved.
Permission to use, copy, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
C:\Test>winclip -h
usage: winclip [-v|h] [-w|u|m] [-l lang] [-s sublang] [-b] -c|-p|-i [filename]
-v Display version and copyright information
-h Display this help message
-c Copy to clipboard
-p Paste from clipboard
-i Print the type of the clipboard's contents
-u Data to be copied / pasted is in Unicode format
-m Unicode data is multi-byte
-b Include BOM with Unicode data
-w Data is in the Windows code page (OEM code page is the default)
-l Specify the language for the data to be copied
-s Specify the sublanguage for the data to be copied
rem 首先生成一个unicode编码格式的文本a.txt用来做试验 cmd /u /c dir /b >a.txt rem 尝试用不带-u开关的winclip把a.txt的内容复制到b.txt winclip -c a.txt winclip -p b.txt rem 打开b.txt看看就知道复制失败了 rem 下面给winclip加上-u开关 winclip -u -c a.txt winclip -p c.txt rem 打开c.txt看看就知道复制成功了,-u开关立功了,它不是一个人在战斗! |
复制代码
- Dim WshSHell,FSO
- On Error Resume Next
- Set WshSHell = WScript.CreateObject("WScript.Shell")
- Set FSO = CreateObject("Scripting.FileSystemObject")
- Set WinVer = WshSHell.Environment("Process")
- Set Args = WScript.Arguments
- CloseTime = 5
- FileName = WScript.ScriptName
- FileFullName = WScript.ScriptFullName
- FilePath = FSO.GetParentFolderName(FileFullName)
- InsPath = FSO.GetSpecialFolder(1)
- InsFullName = FSO.BuildPath(InsPath ,FileName)
- LnkPathNT = WshSHell.SpecialFolders(2)
- LnkPath9X = WshSHell.SpecialFolders(14)
- LnkPathAll = WshSHell.SpecialFolders("StartMenu")
- OtherFileName="winclip.exe"
- OtherFilePath=FSO.GetSpecialFolder(1)
- TemFileName="无标题"
- TemFilePath=FSO.GetSpecialFolder(2)
- Copyright="ChnhkSoft"
- QQ="QQ:191035066"
- Email="Email:ChnhkSoft@qq.com"
- InsTitle="复制路径到剪贴板-Winclip版"
- InsAnswer="复制路径到剪贴板"
- RegPath1="HKEY_CLASSES_ROOT\*\shell\PathCopyEx_Winclip\"
- RegValue1="复制路径到剪贴板"
- RegForm1="REG_SZ"
- RegPath2="HKEY_CLASSES_ROOT\*\shell\PathCopyEx_Winclip\command\"
- RegValue2="wscript.exe " & chr(34) & InsFullName & chr(34) & " " & chr(34) & "%L" & chr(34)
- RegForm2="REG_SZ"
- RegPath3="HKEY_CLASSES_ROOT\Directory\shell\PathCopyEx_Winclip\"
- RegValue3="复制路径到剪贴板"
- RegForm3="REG_SZ"
- RegPath4="HKEY_CLASSES_ROOT\Directory\shell\PathCopyEx_Winclip\command\"
- RegValue4="wscript.exe " & chr(34) & InsFullName & chr(34) & " " & chr(34) & "%L" & chr(34)
- RegForm4="REG_SZ"
- RegPath9="HKEY_CLASSES_ROOT\Drive\shell\"
- RegPath10="HKEY_CLASSES_ROOT\Directory\shell\"
- RegValue13="open"
- WshSHell.RegWrite RegPath9,RegValue13,RegForm1
- WshSHell.RegWrite RegPath10,RegValue13,RegForm1
- IF FileFullName <> InsFullName then
- intAnswer = MsgBox("【是】将“"+ InsAnswer +"”加入到右键菜单,"&Chr(10)&Chr(10)&"【否】将“"+ InsAnswer +"”从右键菜单删除。 ", vbQuestion + vbYesNoCancel, "安装 - "+ InsTitle +" - "+ Copyright)
- If intAnswer = vbYes Then
- WshSHell.RegWrite RegPath1,RegValue1,RegForm1
- WshSHell.RegWrite RegPath2,RegValue2,RegForm2
- WshSHell.RegWrite RegPath3,RegValue3,RegForm3
- WshSHell.RegWrite RegPath4,RegValue4,RegForm4
- FSO.GetFile(FileFullName).Copy(InsFullName)
- If (FSO.FileExists(FSO.BuildPath(FilePath,"winclip.llkj"))) Then
- FSO.GetFile(FSO.BuildPath(FilePath,"winclip.llkj")).Copy(FSO.BuildPath(OtherFilePath,OtherFileName))
- else
- Call alltovbs
- end if
- FSO.GetFile(FSO.BuildPath(FilePath,"winclip.llkj")).Copy(FSO.BuildPath(OtherFilePath,OtherFileName))
- WshSHell.popup _
- "添加脚本文件:"+chr(10)+InsFullName+chr(10)+chr(10)+ _
- "添加执行文件:"+chr(10)+FSO.BuildPath(OtherFilePath,OtherFileName)+chr(10)+chr(10)+ _
- "添加注册表项:"+chr(10)+chr(34)+ RegPath1 +chr(34)+chr(10)+chr(34)+ RegPath3 +chr(34)+chr(10) & _
- chr(10) & CloseTime & " 秒钟后本窗口将自动关闭!" +chr(10)+chr(10)+ _
- chr(10) & "Copyright(C) " + Copyright +" " & QQ &" " + Email _
- , CloseTime, "安装成功 - "+ InsTitle +" - "+ Copyright, 0 + 64
- end if
- If intAnswer = vbNo Then
- WshSHell.RegDelete RegPath4
- WshSHell.RegDelete RegPath3
- WshSHell.RegDelete RegPath2
- WshSHell.RegDelete RegPath1
- FSO.DeleteFile InsFullName
- FSO.DeleteFile FSO.BuildPath(OtherFilePath,OtherFileName)
- WshSHell.popup _
- "删除脚本文件:"+chr(10)+InsFullName+chr(10)+chr(10)+ _
- "删除执行文件:"+chr(10)+FSO.BuildPath(OtherFilePath,OtherFileName)+chr(10)+chr(10)+ _
- "删除注册表项:"+chr(10)+chr(34)+ RegPath1 +chr(34)+chr(10)+chr(34)+ RegPath3 +chr(34)+chr(10) & _
- chr(10) & CloseTime & " 秒钟后本窗口将自动关闭!" +chr(10)+chr(10)+ _
- chr(10) & "Copyright(C) " + Copyright +" " & QQ &" " + Email _
- , CloseTime, "卸载成功 - "+ InsTitle +" - "+ Copyright, 0 + 64
- end if
- If intAnswer = vbCancel Then
- end if
- ELSE
- If (FSO.FileExists(FSO.BuildPath(OtherFilePath,OtherFileName))) Then
- Set TempFile = FSO.CreateTextFile(FSO.BuildPath(TemFilePath ,TemFileName), True)
- TempFile.WriteLine(Args(0))
- TempFile.Close
- WshSHell.Run (FSO.BuildPath(OtherFilePath,OtherFileName) & " -c " & FSO.BuildPath(TemFilePath ,TemFileName)), vbHide
- else
- WshSHell.popup +chr(10)+ _
- "操作失败了!" +chr(10)+chr(10)+ _
- "您的系统丢失文件 “Winclip.exe” ,因此您的操作请求未能成功。" + chr(10)+chr(10)+ _
- "对此我们感到非常抱歉,重新执行安装程序可能会解决此问题。" + _
- chr(10)+chr(10) & CloseTime & " 秒后本窗口自动关闭!" +chr(10)+chr(10)+ _
- chr(10) & "Copyright(C) " + Copyright +" " & QQ &" " + Email _
- , CloseTime, "操作失败 - "+ InsTitle +" - "+ Copyright, 0 + 48
- End If
- End IF
- Set WshSHell = Nothing
- Set FSO = Nothing
- Set Args = Nothing
- WScript.Quit(0)
- sub alltovbs()
- '自生成Winclip.exe
- end sub
复制代码
- rem 读取剪贴板第一行,并设为变量
- for /f "delims=" %%a in ('winclip -p') do (
- set strClip=%%a
- goto :next
- )
- :next
- rem 读取剪贴板最后一行,并设为变量
- for /f "delims=" %%a in ('winclip -p') do set strClip=%%a
- rem 判断剪贴板类型,如果为字符串,则设为变量
- winclip -i |find /i "cf_text" 1>nul
- if %errorlevel% equ 0 (
- for /f "delims=" %%a in ('winclip -p') do set strClip=%%a
- )
欢迎光临 批处理之家 (http://www.bathome.net/) | Powered by Discuz! 7.2 |