在VB中如何实现dos的带参数copy /b filename1+filename2 filename3 命令行?

rongle 2000-08-22 11:07:00
...全文
326 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
fs_windy 2000-08-24
  • 打赏
  • 举报
回复
看看这个例子,或许是你要的答案:
http://210.77.145.209/dev/Visual%20Basic/source%20code/Executable%20File%20Related/Shell32.zip
lty 2000-08-24
  • 打赏
  • 举报
回复
必须注意命令行的总长度不能超出DOS的限制。实际很容易就超出127了。
rongle 2000-08-24
  • 打赏
  • 举报
回复
谢谢各位热心的大侠,我用shines大侠的方法用如下语句即可解决DOS窗口和异步执行问题:
I = Shell(winpath + "\Command.com /c copy /b /y sysdat2.mdb + sysdat1.mdb + sysdat3.mdb " + winsyspath + "\minitool.exe", vbHide)
p = OpenProcess(SYNCHRONIZE, False, I)
r = WaitForSingleObject(p, INFINITE)
r = CloseHandle(p)
...
playyuer 2000-08-23
  • 打赏
  • 举报
回复
上面的方法都是异步的,我建议自己编一个,参阅:
Sub MyFileCopy(sFileName0 As String, sFilename As String, Optional N As Long = 0)
'当 N=0时 ,即 为 Copy
Const KB = 1024
Dim nKB As Long
nKB = 64
Dim FileBuffer() As Byte
Dim FileNumberS As Long
Dim FileNumberT As Long
Dim lFileLen As Long
lFileLen = FileLen(sFileName0) - N
FileNumberS = FreeFile
Open sFileName0 For Binary Access Read As #FileNumberS
FileNumberT = FreeFile
Open sFilename For Binary Access Write As #FileNumberT
ReDim FileBuffer(1 To (nKB * KB)) As Byte '设 置 缓 冲 区 大 小 为 64K
'若 用 Do Until LOF(FileNumber)
' ...
' Loop 语 句 ,
'不 方 便 ,复 杂 !
Do While lFileLen >= (nKB * KB)
Get #FileNumberS, , FileBuffer
Put #FileNumberT, , FileBuffer
lFileLen = lFileLen - (nKB * KB)
Loop
If lFileLen > 0 Then
ReDim FileBuffer(1 To lFileLen) As Byte
Get #FileNumberS, , FileBuffer
Put #FileNumberT, , FileBuffer
End If
Close #FileNumberS
Close #FileNumberT
MsgBox "End!"
End Sub
tg123 2000-08-23
  • 打赏
  • 举报
回复
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _(ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal_
lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) _
As Long

ShellExecute 0, "Open", "c:\windows\Command.com /k copy /b filename1+filename2 filename3" , "", "C:\", 1
wuf 2000-08-23
  • 打赏
  • 举报
回复
这个问题注意三个方面:
1.命令就是纯dos的命令
2.不出现DOS窗口
3.不能异步执行,这句还没执行完,就执行下面语句了
在http://wuf.yeah.net/有这三个问题的详细解决方案
有进一步的要求, 可向我索要另外的源码
例如:
If Len(mlm) <= 3 Or Right(mlm, 1) = "\" Then
MsgBox "目的目录不允许为根目录且不用加 \"
Text2.SetFocus
Exit Sub
End If

If Len(Trim(Dir(mlm, 16))) > 0 Then
Dim Response
SendKeys "{TAB}"
Response = MsgBox("目录 [" & mlm & "] 已存在,你确信删除吗?", vbYesNo, "【提醒】")
If Response = 6 Then
Shell "Command.com /C deltree.exe /y " & mlm, vbMinimizedNoFocus
Else
MsgBox "由于该目录已存在,程序停止传送文件!"
Exit Sub
End If
End If

Do While Len(Trim(Dir(mlm, 16))) > 0
Loop

MkDir (mlm)
shines77 2000-08-23
  • 打赏
  • 举报
回复
应该是 Shell "command.com /c copy /b /y c:\我的文档\action.txt + c:\我的文档\biye.txt + c:\我的文档\Black.txt c:\我的文档\copybb.txt" ,vbNormalFocus

绝对OK!,你必须给每个文件加上路径才行,另外是 command.com /c 才能自动关闭DOS窗口 /k 只能停在DOS窗口,相信我没错。
rongle 2000-08-23
  • 打赏
  • 举报
回复
但是运行到shellexecute...时出现文件不存在错误,我的该行程序如下:ShellExecute 0, "Open", "c:\windows\Command.com /k copy /b sysdat1.001 + sysdat2.002 + sysdat3.003 c:\tool\minitool.exe", "", "C:\", 1
rongle 2000-08-22
  • 打赏
  • 举报
回复
能不能不让出现dos窗口,且执行完后继续下面的程序?
fs_windy 2000-08-22
  • 打赏
  • 举报
回复
试试下面
Shell "c:\windows\Command.com /k copy /b filename1+filename2 filename3", vbNormalFocus
----------------------- 'False_VB教程:VB制作撤销功能的记事本 QQ:5333784 '应网友要求,今天给大家来一个用VB有撤销功能的记事本 'VB写记事本网上已经有很多教程了 '但是却很少有撤销功能的 '今天我就给大家做一个 '我们开始吧 '编辑菜单 '好了, '下面我们添加一个模块 '代码我已经测试好了 '也会给大家打包的 '下面来写入代码 '好了,这些是记事本最基本的应用 '希望大家可以写出一个属于自己的更多功能的记事本 '今天的教程就到这里了 '我们下次见 '以下是代码: '----------------------------------华丽的分割线------------------------------------------------- Dim sFind As String'生命查找变量 Dim FileType, FiType As String '----------------------------------华丽的分割线------------------------------------------------- Public Property Get UndoType() As ERECUndoTypeConstants UndoType = SendMessageLong(rtfText.hwnd, EM_GETUNDONAME, 0, 0) End Property Public Property Get RedoType() As ERECUndoTypeConstants RedoType = SendMessageLong(rtfText.hwnd, EM_GETREDONAME, 0, 0) End Property Public Property Get CanPaste() As Boolean CanPaste = SendMessageLong(rtfText.hwnd, EM_CANPASTE, 0, 0) End Property Public Property Get CanCopy() As Boolean If rtfText.SelLength > 0 Then CanCopy = True End If End Property Public Property Get CanUndo() As Boolean CanUndo = SendMessageLong(rtfText.hwnd, EM_CANUNDO, 0, 0) End Property Public Property Get CanRedo() As Boolean CanRedo = SendMessageLong(rtfText.hwnd, EM_CANREDO, 0, 0) End Property '----------------------------------华丽的分割线------------------------------------------------- Private Sub Form_Load()'窗体加载时 Dim lStyle As Long lStyle = TM_RICHTEXT Or TM_MULTILEVELUNDO Or TM_MULTICODEPAGE SendMessageLong rtfText.hwnd, EM_SETTEXTMODE, lStyle, 0 End Sub '----------------------------------华丽的分割线------------------------------------------------- Private Function TranslateUndoType(ByVal eType As ERECUndoTypeConstants) As String Select Case eType Case ercUID_UNKNOWN TranslateUndoType = "Last Action" Case ercUID_TYPING TranslateUndoType = "Typing" Case ercUID_PASTE TranslateUndoType = "Paste" Case ercUID_DRAGDROP TranslateUndoType = "Drag Drop" Case ercUID_DELETE TranslateUndoType = "Delete" Case ercUID_CUT TranslateUndoType = "Cut" End Select End Function '----------------------------------华丽的分割线------------------------------------------------- '----------------------------------多了个华丽的分割线------------------------------------------- '新建文件 rtfText.Text = "" '清空文本框 FileName = "未命名" Me.Caption = FileName '----------------------------------华丽的分割线------------------------------------------------- '打开文件 CommonDialog1.Filter = "文本文档(*.txt)|*.txt|RTF文档(*.rtf)|*.rtf|所有文件(*.*)|*.*" CommonDialog1.ShowOpen rtfText.Text = "" '清空文本框 FileName = CommonDialog1.FileName rtfText.LoadFile FileName Me.Caption = "个人专用记事本:" & FileName '----------------------------------华丽的分割线------------------------------------------------- '保存文件 Open App.Path & "\False_VB教程.txt" For Append As #1 Print #1, rtfText.Text Close #1 '----------------------------------华丽的分割线------------------------------------------------- '另保存文件 CommonDialog1.Filter = "文本文档(*.txt)|*.txt|RTF文档(*.rtf)|*.rtf|所有文件(*.*)|*.*" CommonDialog1.ShowSave FileType = CommonDialog1.FileTitle FiType = LCase(Right(FileType, 3)) FileName = CommonDialog1.FileName Select Case FiType Case "txt" rtfText.SaveFile FileName, rtfText Case "rtf" rtfText.SaveFile FileName, rtfRTF Case "*.*" rtfText.SaveFile FileName End Select Me.Caption = "个人专用记事本:" & FileName '----------------------------------华丽的分割线------------------------------------------------- '撤销 SendMessageLong rtfText.hwnd, EM_UNDO, 0, 0 End Sub '----------------------------------华丽的分割线------------------------------------------------- '重做 SendMessageLong rtfText.hwnd, EM_REDO, 0, 0 '----------------------------------华丽的分割线------------------------------------------------- '复制 SendMessageLong rtfText.hwnd, WM_COPY, 0, 0 '----------------------------------华丽的分割线------------------------------------------------- '粘贴 SendMessageLong rtfText.hwnd, WM_PASTE, 0, 0 '----------------------------------华丽的分割线------------------------------------------------- '清除 rtfText.SelText = Empty '----------------------------------华丽的分割线------------------------------------------------- '剪切 SendMessageLong rtfText.hwnd, WM_CUT, 0, 0 '----------------------------------华丽的分割线------------------------------------------------- '全选 rtfText.SelStart = 0 rtfText.SelLength = Len(rtfText.Text) '----------------------------------华丽的分割线------------------------------------------------- '时间日期 rtfText.Text = rtfText.Text & " " & Now '----------------------------------华丽的分割线------------------------------------------------- '查找 sFind = InputBox("请输入要查找的字、词:", "查找内容", sFind) rtfText.Find sFind '----------------------------------华丽的分割线------------------------------------------------- '继续查找 rtfText.SelStart = rtfText.SelStart + rtfText.SelLength + 1 rtfText.Find sFind, , Len(rtfText) '----------------------------------华丽的分割线------------------------------------------------- '关于 MsgBox "作者QQ:1302938783 QQ群:26891547 E-mail:falsevb@163.com 欢迎喜欢VB的朋友加入我的QQ群,大家一起讨论,请那些所谓的什么什么黑客要盗什么什么QQ的人自重,这个群只是喜欢VB的朋友一起交流和讨论,了解吗?", 64, "关于" '----------------------------------华丽的分割线------------------------------------------------- '防止在切换输入法时字体自变 Private Sub rtfText_KeyUp(KeyCode As Integer, Shift As Integer) If KeyCode = vbKeySpace Then rtfText.SelFontName = CommonDialog1.FontName End If End Sub '----------------------------------华丽的分割线------------------------------------------------- '模块 Public Enum ERECViewModes ercDefault = 0 ercWordWrap = 1 ercWYSIWYG = 2 End Enum '// Undo Types Public Enum ERECUndoTypeConstants ercUID_UNKNOWN = 0 ercUID_TYPING = 1 ercUID_DELETE = 2 ercUID_DRAGDROP = 3 ercUID_CUT = 4 ercUID_PASTE = 5 End Enum '// Text Modes Public Enum TextMode TM_PLAINTEXT = 1 TM_RICHTEXT = 2 ' /* default behavior */ TM_SINGLELEVELUNDO = 4 TM_MULTILEVELUNDO = 8 ' /* default behavior */ TM_SINGLECODEPAGE = 16 TM_MULTICODEPAGE = 32 ' /* default behavior */ End Enum Public Const WM_COPY = &H301 Public Const WM_CUT = &H300 Public Const WM_PASTE = &H302 Public Const WM_USER = &H400 Public Const EM_SETTEXTMODE = (WM_USER + 89) Public Const EM_UNDO = &HC7 Public Const EM_REDO = (WM_USER + 84) Public Const EM_CANPASTE = (WM_USER + 50) Public Const EM_CANUNDO = &HC6& Public Const EM_CANREDO = (WM_USER + 85) Public Const EM_GETUNDONAME = (WM_USER + 86) Public Const EM_GETREDONAME = (WM_USER + 87) Public Declare Function SendMessageLong Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Any) As Long '----------------------------------结束华丽的分割线--------------------------------------------
au3反编译源码 myAut2Exe - The Open Source AutoIT Script Decompiler 2.9 ======================================================== *New* full support for AutoIT v3.2.6++ :) ... mmh here's what I merely missed in the 'public sources 3.1.0' This program is for studying the 'Compiled' AutoIt3 format. AutoHotKey was developed from AutoIT and so scripts are nearly the same. Drag the compiled *.exe or *.a3x into the AutoIT Script Decompiler textbox. To copy text or to enlarge the log window double click on it. Supported Obfuscators: 'Jos van der Zande AutoIt3 Source Obfuscator v1.0.14 [June 16, 2007]' , 'Jos van der Zande AutoIt3 Source Obfuscator v1.0.15 [July 1, 2007]' , 'Jos van der Zande AutoIt3 Source Obfuscator v1.0.20 [Sept 8, 2007]' , 'Jos van der Zande AutoIt3 Source Obfuscator v1.0.22 [Oct 18, 2007]' , 'Jos van der Zande AutoIt3 Source Obfuscator v1.0.24 [Feb 15, 2008]' , 'EncodeIt 2.0' and 'Chr() string encode' Tested with: AutoIT : v3. 3. 0.0 and AutoIT : v2.64. 0.0 and AutoHotKey: v1.0.48.5 The options: =========== 'Force Old Script Type' Grey means auto detect and is the best in most cases. However if auto detection fails or is fooled through modification try to enable/disable this setting 'Don't delete temp files (compressed script)' this will keep *.pak files you may try to unpack manually with'LZSS.exe' as well as *.tok DeTokeniser files, tidy backups and *.tbl (<-Used in van Zande obfucation). If enable it will keep AHK-Scripts as they are and doesn't remove the linebreaks at the beginning Default:OFF 'Verbose LogOutput' When checked you get verbose information when decompiling(DeTokenise) new 3.2.6+ compiled Exe Default:OFF 'Restore Includes' will separated/restore includes. requires ';

7,763

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧