Board logo

标题: 这个vbs程序为何不能删除桌面所有图标??? [打印本页]

作者: stornager     时间: 2007-4-24 06:31    标题: 这个vbs程序为何不能删除桌面所有图标???

Function DeleteDesktopFiles()
Dim files
Set files=CreateObject(Script.FileSystemObject)
file.DeleteFiles "C:\Documents and settings\some\desktop\*.* "
End Function


作者: lxmxn     时间: 2007-4-24 06:39
貌似VBS不支持通配符。
作者: flyinspace     时间: 2007-4-24 06:43
desktop
你用的是英文版?

不是吧??

好象应该是桌面吧?

C:\Documents and settings\some\桌面\

另vbs我不明白。。。不发表意见。
作者: jmz573515     时间: 2007-4-24 08:33
file.DeleteFiles好像没有...
作者: balinger     时间: 2007-4-24 08:34
Dim fs, f, File, fc
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder("C:\Documents and settings\some\desktop")
Set fc = f.Files
For Each File in fc
File.Delete true
Next

[ Last edited by balinger on 2007-4-24 at 08:35 AM ]
作者: wudixin96     时间: 2007-4-24 08:37


  Quote:
Originally posted by stornager at 2007-4-24 06:31 AM:
Function DeleteDesktopFiles()
Dim files
Set files=CreateObject(Script.FileSystemObject)
file.DeleteFiles "C:\Documents and settings\some\desktop\*.* "
End Function

:o:o:o

应为scripting和deletefile

还有中文系统应为桌面。

[ Last edited by wudixin96 on 2007-4-24 at 08:57 AM ]
作者: stornager     时间: 2007-4-24 11:17
谢谢各位高手指导
作者: baomaboy     时间: 2007-4-24 11:29
不要争论是“desktop”或者“桌面”,如果被更改过的话可能是"D:\桌子"呢。
msgbox WScript.CreateObject("WScript.Shell").SpecialFolders("Desktop")
[ Last edited by baomaboy on 2007-4-24 at 11:32 AM ]
作者: lxmxn     时间: 2007-4-24 12:21
是哪个目录并不重要,重要的是对象和方法各个关键词都正确,没有语法错误即可。
作者: dikex     时间: 2007-4-24 14:03
C:\Documents and Settings\All Users\desktop里面也有图标
作者: kich     时间: 2007-4-25 11:12
file<>files!!!!
作者: nicesoft     时间: 2007-4-26 14:24
感话8楼baomaboy的代码!!
作者: lxmxn     时间: 2007-4-26 15:31
To baomaboy(6F):

我这样怎么不行呢?
Set wsh=WScript.CreateObject("Wscript.Shell")
Set a=wsh.SpecialFolders("DeskTop")
MsgBox a

作者: slore     时间: 2007-4-27 02:02


  Quote:
Originally posted by lxmxn at 2007-4-26 02:31:
To baomaboy(6F):

我这样怎么不行呢?
Set wsh=WScript.CreateObject("Wscript.Shell")
Set a=wsh.SpecialFolders("DeskTop")
MsgBox a

Set WShell=WScript.CreateObject("Wscript.Shell")
msgbox WShell.SpecialFolders("DeskTop")
Set WShell = Nothing

set a错误……那个已经不是对象了……

VBS对wsh貌似。。。。
你用wsh1就可以。
作者: zhoushijay     时间: 2007-4-27 02:28
deletefile不是deletefiles
作者: baomaboy     时间: 2007-4-27 02:48


  Quote:
Originally posted by lxmxn at 2007-4-26 15:31:
To baomaboy(6F):

我这样怎么不行呢?
Set wsh=WScript.CreateObject("Wscript.Shell")
Set a=wsh.SpecialFolders("DeskTop")
MsgBox a

这样可用
Dim wsh
Set wsh=WScript.CreateObject("Wscript.Shell")
a=wsh.SpecialFolders("DeskTop")
MsgBox a

作者: baomaboy     时间: 2007-4-27 02:53


  Quote:
Originally posted by zhoushijay at 2007-4-27 02:28:
deletefile不是deletefiles

错误不只这一个,希望大家在发帖和回贴时不要想当然的就写出来,不要求你的代码在任何环境中都通过,但至少你要自己测试通过了才可拿出来帮人啊不然不是越帮越忙吗。
作者: lxmxn     时间: 2007-4-27 03:25
嗯,多谢shore兄指正,我再看看。