vbs提示没有在该机执行windows脚本宿主的权限。请与系统管理员联系(没有在指定的windows上运行是怎么回事儿)怎么可以错过

随心笔谈2年前发布 编辑
132 0
🌐 经济型:买域名、轻量云服务器、用途:游戏 网站等 《腾讯云》特点:特价机便宜 适合初学者用 点我优惠购买
🚀 拓展型:买域名、轻量云服务器、用途:游戏 网站等 《阿里云》特点:中档服务器便宜 域名备案事多 点我优惠购买
🛡️ 稳定型:买域名、轻量云服务器、用途:游戏 网站等 《西部数码》 特点:比上两家略贵但是稳定性超好事也少 点我优惠购买


‘****************** Const ****************
‘—- CuRsorTypeEnum Values —-
Const adOpenForwardOnly=0
Const adOpenKeyset=1
Const adOpenDynamic=2
Const adOpenStatic=3

‘—- LockTypeEnum Values —-
Const adLockReadOnly=1
Const adLockPessimistic=2
Const adLockOptimistic=3
Const adLockBatchOptimistic=4

‘—- CuRsorLocationEnum Values —-
Const adUseServer=2
Const adUseClient=3

‘—- Custom Values —-
Const cuDSN=”test”

Const cuUsername=”sa”
Const cuPassword=””

‘*************** main sub ******************

Call ImageExport()

‘*************** define function ***********

Function ImageExport()
‘on error resume next
Dim sSQL,Rs,Conn,sfzRs,xml
Dim Ados,fso,f,oShell,sErrFile,sSucFile,iErr,iSuc ‘iSuc 文件总数
Dim PicPath,PhysicPath,DelCount ‘删除文件数
Set fso=CreateObject(“Scripting.FileSystemObject”)

‘ Create Stream Object
set Ados=CreateObject(“Adodb.Stream”)
Ados.Mode=3
Ados.Type=1

Set Conn=CreateObject (“adodb.Connection”)
Conn.CuRsorLocation=adUseClient
Call Init_Connection(Conn)
Set Rs=CreateObject (“adodb.recordset”)
Set sfzRs=CreateObject (“adodb.recordset”)

sSQL=”select sPath,sFile from ScanFile”
sfzRs.Open sSQL,Conn,adOpenForwardOnly
iSuc=sfzRs.RecordCount

‘Get SFZH From DataBase and import images
while not sfzRs.EOF
PhysicPath=”E:\VBS删除照片小程序” ‘物理路径
Ados.Open
PicPath=PhysicPath & sfzRs(“sPath”) &”” & sfzRs(“sFile”)
If (fso.FileExists(PicPath)) Then
fso.DeleteFile(PicPath)
DelCount=DelCount+1
end if
sfzRs.MoveNext
Ados.Close
if iSuc-DelCount=iSuc Then
DelCount=0
end if
wend

sfzRs.Close
Conn.Close

‘Release Object
set Rs=nothing:set sfzRs=nothing:set Conn=nothing:set Ados=nothing:set fso=nothing

msgbox “共需要删除” & iSuc & “张照片,其中” & DelCount & “张照片删除成功,” &iSuc-DelCount & “张照片未找到!”,64 ,”照片删除”

‘Quit
WScript.Quit

End Function

Function Init_Connection(Conn)
on error resume next
ConnStr=”Provider=SQLOLEDB;Data Source=192.168.64.114;” & _
“Initial Catalog=VoteInfo;User Id=sa;Password=123456;timeout=50”
Conn.Open ConnStr

If Err.number Then
msgbox “数据库联接失败”,16 ,”照片删除”
exit function
End If
End Function

© 版权声明

相关文章