China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-04 11:07
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » Why can't this VBS program delete all icons on the desktop??? View 2,506 Replies 17
Original Poster Posted 2007-04-24 06:31 ·  中国 湖北 武汉 电信
中级用户
★★
scriptlover
Credits 328
Posts 131
Joined 2007-03-25 22:17
19-year member
UID 82910
Gender Male
Status Offline
```vb
Function DeleteDesktopFiles()
Dim files
Set files=CreateObject(Script.FileSystemObject)
file.DeleteFiles "C:\Documents and settings\some\desktop\*.* "
End Function


```
Floor 2 Posted 2007-04-24 06:39 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
20-year member
UID 59080
Status Offline
It seems that VBS does not support wildcards.
Floor 3 Posted 2007-04-24 06:43 ·  中国 广东 广州 联通
银牌会员
★★★
Credits 1,206
Posts 517
Joined 2007-03-25 01:18
19-year member
UID 82819
Gender Male
Status Offline
desktop
Are you using the English version?

No way??

It seems it should be desktop?

C:\Documents and settings\some\Desktop\

Another thing, I don't understand vbs... I won't give an opinion.
知,不觉多。不知,乃求知
Floor 4 Posted 2007-04-24 08:33 ·  中国 辽宁 本溪 联通
银牌会员
★★★
Credits 1,212
Posts 464
Joined 2006-12-13 21:11
19-year member
UID 73417
Gender Male
Status Offline
file.DeleteFiles doesn't seem to have...
Floor 5 Posted 2007-04-24 08:34 ·  中国 福建 福州 连江县 电信
中级用户
★★
Credits 356
Posts 115
Joined 2004-07-27 00:00
22-year member
UID 29114
Gender Male
Status Offline
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 ]
Floor 6 Posted 2007-04-24 08:37 ·  中国 浙江 杭州 联通
银牌会员
★★★
Credits 1,928
Posts 931
Joined 2007-01-06 11:46
19-year member
UID 75624
Gender Male
Status Offline
Originally posted by stornager at 2007-4-24 06:31 AM:
Function DeleteDesktopFiles()
Dim files
Set files=CreateObject("Scripting.FileSystemObject")
file.DeleteFile "C:\Documents and settings\some\Desktop\*.*"
End Function

:o:o:o

Should be scripting and deletefile

And for Chinese systems, it should be Desktop.

[ Last edited by wudixin96 on 2007-4-24 at 08:57 AM ]
Floor 7 Posted 2007-04-24 11:17 ·  中国 湖北 武汉 电信
中级用户
★★
scriptlover
Credits 328
Posts 131
Joined 2007-03-25 22:17
19-year member
UID 82910
Gender Male
Status Offline
Thanks to all the experts for your guidance
Floor 8 Posted 2007-04-24 11:29 ·  中国 河北 保定 联通
银牌会员
★★★
Credits 1,513
Posts 554
Joined 2005-12-30 00:50
20-year member
UID 48180
Gender Male
Status Offline
Don't argue whether it's "desktop" or "桌面". If it has been changed, it might be "D:\桌子".

msgbox WScript.CreateObject("WScript.Shell").SpecialFolders("Desktop")


[ Last edited by baomaboy on 2007-4-24 at 11:32 AM ]
Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
lxmxn +1 2007-04-24 12:20
Floor 9 Posted 2007-04-24 12:21 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
20-year member
UID 59080
Status Offline
Which directory it is doesn't matter. What matters is that each keyword of the object and method is correct and there are no grammar errors.
Floor 10 Posted 2007-04-24 14:03 ·  中国 广东 广州 白云区 电信
高级用户
★★★
潜水修练批处理
Credits 788
Posts 366
Joined 2006-12-31 02:43
19-year member
UID 75048
Gender Male
Status Offline
There are also icons in C:\Documents and Settings\All Users\desktop
Floor 11 Posted 2007-04-25 11:12 ·  中国 上海 上海乾万网络(QianWan_Network)有限公司(电信出口)
中级用户
★★
Credits 397
Posts 168
Joined 2006-10-08 10:07
19-year member
UID 64934
Status Offline
Floor 12 Posted 2007-04-26 14:24 ·  中国 广东 广州 番禺区 电信
初级用户
Credits 98
Posts 47
Joined 2007-01-28 05:39
19-year member
UID 77912
Gender Male
Status Offline
Comments from user "baomaboy" on floor 8: The code!!
Floor 13 Posted 2007-04-26 15:31 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
20-year member
UID 59080
Status Offline
To baomaboy(6F):

Why doesn't this work for me?
Set wsh=WScript.CreateObject("Wscript.Shell")
Set a=wsh.SpecialFolders("DeskTop")
MsgBox a
Floor 14 Posted 2007-04-27 02:02 ·  中国 陕西 西安 电信
铂金会员
★★★★
Credits 5,212
Posts 2,478
Joined 2007-02-08 23:39
19-year member
UID 79003
Gender Male
Status Offline
Originally posted by lxmxn at 2007-4-26 02:31:
To baomaboy(6F):

Why doesn't this work for me?
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

The set a is wrong... That is no longer an object...

For VBS with wsh...
You can use wsh1.
Floor 15 Posted 2007-04-27 02:28 ·  中国 新疆 乌鲁木齐 天山区 电信
高级用户
★★★
Autowalk
Credits 845
Posts 375
Joined 2007-03-03 01:58
19-year member
UID 80606
Gender Male
Status Offline
deletefile is not deletefiles
Forum Jump: