标题: 请教vbs 调用批命令的问题?
[打印本页]
作者: ooaf
时间: 2009-2-16 00:14
标题: 请教vbs 调用批命令的问题?
请教vbs 调用批命令的问题?
请问下面的代码有问题吗?
代码:
Sh.Run "cmd /c call set Q=pc.htm&if exist c:\%Q% move /y c:\%Q% %windir%\%Q%&starT %windir%\%Q%",0
下面的代码可以精简吗?
代码:
Sh.Run "cmd /c if exist c:\pc.htm for %%a in (c:\pc.htm) do if %%~za lss 20480 del %%a"
作者: everest79
时间: 2009-2-16 01:39
Dim FSO,WSH
Set FSO=CreateObject("Scripting.FileSystemObject")
Set WSH=CreateObject("WScript.Shell")
If FSO.FileExists("C:\pc.htm") Then
FSO.MoveFile "C:\pc.htm",FSO.GetSpecialFolder(0) & "\"
WSH.RUN FSO.GetSpecialFolder(0) & "\pc.htm"
End If
Dim FSO
Set FSO=CreateObject("Scripting.FileSystemObject")
If FSO.FileExists("C:\pc.htm") Then
If FSO.GetFile("C:\pc.htm").SIZE < 20480 Then
FSO.DeleteFile("C:\pc.htm")
End If
End If
作者: ooaf
时间: 2009-2-16 10:38
有时候,Scripting.FileSystemObject 对vbs 来说,是致命的弱点。
作者: zhengqian529
时间: 2009-2-16 15:07
FSOx提供了很多操作文件 和文件夹的方法,楼上能够解释下你所说的弱点吗?
作者: zhengqian529
时间: 2009-2-16 15:07
Sh.Run "cmd /c call set Q=pc.htm&if exist c:\%Q% move /y c:\%Q% %windir%\%Q%&starT %windir%\%Q%",0
错误提示能发下吗?
作者: ooaf
时间: 2009-2-16 16:20
Quote: |
Originally posted by zhengqian529 at 2009-2-16 03:07 PM:
Sh.Run "cmd /c call set Q=pc.htm&if exist c:\%Q% move /y c:\%Q% %windir%\%Q%&starT %windir%\%Q%",0
错误提示能发下吗? |
|
这句我改了,网上搜索了一下,加了个call ,以前没有加,运行没反应!
作者: ooaf
时间: 2009-2-16 16:22
Sh.Run "cmd /c if exist c:\pc.htm for %%a in (c:\pc.htm) do if %%~za lss 20480 del %%a"
这句能精简吗?