VBScript自动配置Python语言(3.3)的环境变量

2015-11-21 0 801
VBScript自动配置Python语言(3.3)的环境变量
Option Explicit
Dim pSysEnv
Dim objFSO
Set pSysEnv = CreateObject("WScript.Shell").Environment("System")
Set objFSO=CreateObject("Scripting.FileSystemObject")

Function IsMatch(Str, Patrn)  
  Dim r
  Set r = new RegExp
  r.Pattern = Patrn  
  IsMatch = r.test(Str)
  Set r = Nothing 
End Function  
  
Sub SetEnv(pPath, pValue)
    Dim ExistValueOfPath
    IF pValue <> "" Then
        ExistValueOfPath = pSysEnv(pPath)
        IF Right(pValue, 1) = "\" Then pValue = Left(pValue, Len(pValue)-1)
        If IsMatch(ExistValueOfPath, "\*?" & Replace(pValue, "\", "\\") & "\\?(\b|;)") Then Exit Sub
        If ExistValueOfPath <> "" Then pValue = ";" & pValue
        pSysEnv(pPath) = ExistValueOfPath & pValue
    Else
        pSysEnv.Remove(pPath)
    End IF
End Sub
  
Sub WriteEnv(pPath, pValue)
    pSysEnv(pPath) = pValue
End Sub

WriteEnv "PYTHONHOME", objFSO.GetFolder(".").Path
WriteEnv "PYTHONPATH", objFSO.GetFolder(".").Path
SetEnv "Path", objFSO.GetFolder(".").Path
Set pSysEnv = Nothing
Dim oShell
Set oShell = WScript.CreateObject("WScript.Shell")
oShell.Exec objFSO.GetFolder(".").Path & "\Lib\site-packages\pythonwin\Pythonwin.exe"
Set oShell = Nothing

遇见资源网 ASP/Basic VBScript自动配置Python语言(3.3)的环境变量 http://www.ox520.com/13556.html

常见问题

相关文章

发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务