您好,登錄后才能下訂單哦!
vbs中提示沒有在該機執行windows腳本宿主的權限怎么解決?針對這個問題,這篇文章詳細介紹了相對應的分析和解答,希望可以幫助更多想解決這個問題的小伙伴找到更簡單易行的方法。
以管理員身份運行程序的vbs命令
1、檢查系統是否禁止使用了腳本運行,即打開“INTERNET選項”的“安全”選項卡里“自定義級別”,看看“ActiveX空件及服務”禁用的選項。
2、運行 regsvr32 scrrun.dll,即打開運行輸入CMD,輸入regsvr32 scrrun.dll,再回車。
3、最關鍵的一步,即看看注冊表里的這個位置HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Script Host\Settings在右邊的窗口中是不是有個名為 Enabled的DWORD鍵值,有的話把它刪除或者把值該為 1 即可。
4、重新運行VBS文件即將正常。
VBS批量導入圖片功能
'****************** 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,sFilePath,sImgFile,xml Dim Ados,fso,f,oShell,sErrFile,sSucFile,iErr,iSuc 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") sFilePath=WScript.ScriptFullName sFilePath=left(sFilePath,len(sFilePath)-len(WScript.ScriptName)) ssql="SELECT RYBH, PHOTO FROM TP_ZPXX WHERE (RYBH IN (SELECT DISTINCT RYBH FROM TP_BMKM WHERE (KSZQBH = 18) AND (JFBZ = 1)))" sfzRs.Open sSQL,Conn,adOpenForwardOnly iSuc=sfzRs.RecordCount 'Get SFZH From DataBase and import images while not sfzRs.EOF sImgFile= sFilePath & sfzRs("RYBH") & ".jpg" Ados.Open Ados.Write (sfzRs("PHOTO").GetChunk(4500000)) Ados.SaveToFile sImgFile,1 sfzRs.MoveNext Ados.Close wend sfzRs.Close Conn.Close 'Release Object set Rs=nothing:set sfzRs=nothing:set Conn=nothing:set Ados=nothing msgbox iSuc & "張照片導出成功",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
VBS批量刪除圖片功能
'****************** 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
關于vbs中提示沒有在該機執行windows腳本宿主的權限怎么解決問題的解答就分享到這里了,希望以上內容可以對大家有一定的幫助,如果你還有很多疑惑沒有解開,可以關注億速云行業資訊頻道了解更多相關知識。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。