一勺抹茶

分享代码的乐趣

 

VBS打开一个脚本

习惯用js,但是因为asp本来就是微软的产物,那么用vbs这个同样是微软的产物可以做更多的事情,下面是使用shell:
在网页上如此调用:
<a href="#" class=title2 onclick="openERP(chkCanUseErp())">ERP系統</a>

' VB Script Document
Function ReportFolderStatus(byval stFolder)
   Dim fso, msg
   Set fso = CreateObject("Scripting.FileSystemObject")
   If (fso.FolderExists(stFolder)) Then
      ReportFolderStatus = true
   Else
      ReportFolderStatus = false
   End If
End Function

Function g_CreateFolder(byval strPath)
  dim fo
  set fo=CreateObject("Scripting.FileSystemObject")
  fo.CreateFolder(strPath)
  if err.Number<>0 then  
    g_CreateFolder = true
  else
    g_CreateFolder = false
  end if
   
end Function

sub openERP(byval CanUseERP)
dim objShell

if CanUseERP=True then
 Set objShell=CreateObject("WScript.Shell") '在客户端建立一个shell
 if ReportFolderStatus("c:\TMP") = false then
     if(g_CreateFolder("c:\TMP")= true)  then
    alert "新建c:\TMP失敗,請確認該帳號是否對本機有讀取權限!"
    exit sub
     end if   
 end if
 
 if ReportFolderStatus("J:\lc") = false then
  alert "請確認是否有連接正確的網路磁碟機J!"
  exit sub
 end if
  
 if ReportFolderStatus("c:\dlc91c") = true then
  objShell.Run "j:\lc\ini\WLC",1,FALSE
 elseif ReportFolderStatus("D:\dlc91c") = true then 
  objShell.Run "j:\lc\ini\WLD",1,FALSE
 else
  alert "請確認是否有安裝客戶端!!"
 end if
end if

Set objShell = Nothing

end sub

posted on 2005-12-01 14:13  MoreTea  阅读(353)  评论(0)    收藏  举报

导航