请教如何用vbs删除服务器文件?

青锋-SS 2004-07-21 09:50:53
FSO不知怎么用不了,需要怎么设置啊?
<script language="vbs">
sub delfile1()
Dim oFSO, f1

'' On Error Resume Next

Set oFSO = CreateObject("Scripting.FileSystemObject")
oFSO.DeleteFile(path)
Set oFSO = Nothing

end sub
</script>
错误:ActiveX部件不能创建对象
Set oFSO = Server.CreateObject("Scripting.FileSystemObject")错误:缺少对象“server”


<script language="jscript">
function del()
{
var fso,f1;
fso = new ActiveXObject("Scripting.FileSystemObject");
f1 = fso.GetFile(path);
f1.Delete();
}
</script>
错误:automation 不能创建对象
请教各位,给个建议
...全文
133 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
青锋-SS 2004-07-21
  • 打赏
  • 举报
回复
下面是一个.asp文件的删除例子,是一个OA系统(要配置好多东西)的一个页面,,可以删除服务器文件的。
<script language="vbscript">
sub readpath()
for each node in filenodes
name=node.selectsinglenode("name").text
str=str&"<tr>"
str=str&"<td >"
str=str&"<a target=_blank href='"&httppath&name&"'>"
str=str&name
str=str&"</a>"
str=str&"</td>"
str=str&"<td>"
str=str&"<input type=checkbox id=checkfile value='"&filepath&"\"&name&"'>"
str=str&"</td>"
str=str&"</tr>"
next
end sub

sub delfile()
i=checkfile.length
str="<request><reqtype>删除文件</reqtype>"
if err.number>0 then
if checkfile.checked then
tempid= checkfile.value
str=str&"<file><![CDATA["&tempid&"]]></file>"
end if
else
for i=0 to checkfile.length-1
if checkfile.item(i).checked then
tempid= checkfile.item(i).value
str=str&"<file><![CDATA["&tempid&"]]></file>"
end if
next
end if
str=str&"</request>"
dom.loadxml(str)
set xmlhttp=createobject("Microsoft.xmlhttp")
xmlhttp.open "POST","Mailserver.asp",FALSE
xmlhttp.send dom.xml
str=xmlhttp.responsexml.xml
window.location.reload()
end sub
</script>

另:
Mailserver.asp:
<%
Response.ContentType = "text/xml"
Response.Buffer = False
set dom=server.createobject("microsoft.xmldom")

dom.load request
set rootnode=dom.documentelement
set node=rootnode.selectsinglenode("reqtype")
select case node.text
case "删除文件"
delfiles(rootnode)
Response.write "<?xml version='1.0' encoding='gb2312' ?>"
response.write getxml
end select

function delfiles(root)
on error resume next
set curnodes=root.selectnodes("file")
set fso=server.createobject("scripting.filesystemobject")
for each node in curnodes
path=node.text
fso.deletefile(path)
next

if err.number>0 then
result="<result>"&err.description&"</result>"
else
reuslt="<result>成功</result>"
end if

end function
%>
我现在想用.aspx(c#)做,上面的东西有点不懂,怎么转换成一个代码文件只要能删除服务器文件就行了,请各位帮我重写一下好吗,向各位学习
liuyanlin 2004-07-21
  • 打赏
  • 举报
回复
如果服务器是远程的,我该怎么注册组件啊,
hlep,,
青锋-SS 2004-07-21
  • 打赏
  • 举报
回复
怎么打开FSO服务器端的fso呢?需要怎么设置?
regsvr32 scrrun.dll我刚注册了,也还是不行,同样报:ActiveX部件不能创建对象,是不是还需要其他的.dll

青锋-SS 2004-07-21
  • 打赏
  • 举报
回复
-->在服务器上运行框里运行:cscript <scriptname>.vbs就行了。
不大懂楼上的,服务器上运行框里是指?
BlueDestiny 2004-07-21
  • 打赏
  • 举报
回复
fso须注册组件。
运行->regsvr32 scrrun.dll
  • 打赏
  • 举报
回复
服务器端关闭了fso吧可能~~
pfc001 2004-07-21
  • 打赏
  • 举报
回复
不可以
shauykee 2004-07-21
  • 打赏
  • 举报
回复
写一个删除文件的脚本,然后在服务器上运行框里运行:cscript <scriptname>.vbs就行了。
jhlcss 2004-07-21
  • 打赏
  • 举报
回复
不可以的,vbs是客户端脚本无法删除服务器端文件,即便是客户端文件,也要放开客户端的安全限制才可以
如果要删除服务器端文件用asp脚本来写
zhjh5555 2004-07-21
  • 打赏
  • 举报
回复
在C#中有我的回
青锋-SS 2004-07-21
  • 打赏
  • 举报
回复
ziji up

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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