|
楼主 |
发表于 2011-5-21 22:21
|
显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
回复 33楼 fecmen 的帖子
不要说思路了,我不是连源码都给出了吗,在1楼你还没看吧。
- '*****************************************************************************
- ' FileName: Setup.VBS
- ' Author: baomaboy
- ' Abstract: Excel_VBA自定义函数集安装程序
- '*****************************************************************************
- On Error Resume Next
- Dim WshShell,FSO
- Set WshSHell = WScript.CreateObject("WScript.Shell")
- Set FSO = CreateObject("Scripting.FileSystemObject")
- DllPath = FSO.GetSpecialFolder(1)
- intAnswer = MsgBox("【是】安装[通用工程试验函数集]到系统,"&Chr(10)&Chr(10)&"【否】卸载[通用工程试验函数集]从系统。 ", vbQuestion + vbYesNoCancel, "安装 - 通用工程试验函数集 - by baomaboy")
- If intAnswer = vbYes Then
- For Each Process In GetObject("winmgmts:").ExecQuery("select * from Win32_Process where name='EXCEL.EXE'")
- Process.Terminate (0)
- Next
- FSO.GetFile("GCSY.DLL").Copy(DllPath &"")
- WshSHell.Run ("regsvr32 /s " & FSO.BuildPath(DllPath,"GCSY.DLL")), vbHide
- WScript.Sleep 1365
- dim oXL
- Set oXL = CreateObject("Excel.Application")
- oXL.Workbooks.Add
- Set oAddin = oXL.AddIns.Add("工程试验.SYHS", True)
- oAddin.Installed = True
- oXL.Quit
- Set oXL = Nothing
- WshSHell.popup vbcr & vbcr & "安装 通用工程试验函数集 完成......", 5, "安装成功 - 通用工程试验函数集 - by baomaboy", 0 + 64
- end if
- If intAnswer = vbNo Then
- WshSHell.Run ("regsvr32 /s /u " & FSO.BuildPath(DllPath,"GCSY.DLL")), vbHide
- WScript.Sleep 1365
- FSO.DeleteFile(FSO.BuildPath(DllPath,"GCSY.DLL"))
- WshSHell.popup vbcr & vbcr & "卸载 通用工程试验函数集 完成......", 5, "卸载成功 - 通用工程试验函数集 - by baomaboy", 0 + 64
- end if
- If intAnswer = vbCancel Then
- end if
- Set WshSHell = Nothing
- Set FSO = Nothing
- Set oXL = Nothing
- WScript.Quit(0)
复制代码 |
|