VBS设置系统的环境变量
2013-04-24 16:15
253 查看
程序实现的是系统环境变量设置,更改Enviroment为user可设置用户变量。
Dim currentpath currentpath=createobject("Scripting.FileSystemObject").GetFolder(".").Path MsgBox currentpath Dim ocrpath ocrpath=currentpath&"\Tesseract-OCR" SetTheEnv(ocrpath) Function SetTheEnv(ocrpath) Dim pSysEnv Set pSysEnv = CreateObject("WScript.Shell").Environment("System") pSysEnv("TESSDATA_PREFIX")=ocrpath&"\" Dim ExistValue ExistValue=pSysEnv("path") Dim target,s,exist,appendvalue exist=False appendvalue=ocrpath&";"&ocrpath&"\training" ExistValue=ExistValue&";"&appendvalue ExistValue=reduce(ExistValue,False,";") target=split(ExistValue,";") ExistValue="" For Each s In target If s<>"" Then ExistValue=ExistValue&s&";" End If Next pSysEnv("path")=ExistValue 'ExistValue=pSysEnv("wdir") 'MsgBox("WDIR="&ExistValue) MsgBox "环境设置成功!" End Function Function reduce(srcstr,casesentive,sp) Dim objDict,x,y srcarr=split(Trim(srcstr),sp) Set objDict=createobject("Scripting.Dictionary") For Each x In srcArr If Not casesentive Then y=LCase(x) Else y=x End If If Not objDict.Exists(y) Then If y<>lcase(driverLetter)&"\" Then objDict.Add y,x End If End If Next reduce=Join(objDict.Items,sp) Set objDict=Nothing End Function
相关文章推荐
- 设置系统环境变量立即生效的VBS脚本
- 设置系统环境变量立即生效的VBS脚本
- 设置系统环境变量立即生效的VBS脚本
- 那些年,我写过的设置Windows系统变量的vbs脚本
- python脚本中如何设置系统的环境变量
- Ubuntu 系统中设置环境变量 PATH 的方法
- java 获取系统变量(环境变量和设置变量)
- 系统环境变量的设置Delphi函数
- shell设置系统环境变量的问题
- Android中如何获得一些系统设置和环境变量?
- 命令行对编译环境设置及系统环境变量一览
- VS_ 系统环境变量设置
- java 获取系统变量(环境变量和设置变量)
- php-mac系统 环境变量设置
- ubuntu设置环境变量错误导致系统无法登陆解决方法
- bat脚本设置系统环境变量即时生效
- MAC OS X设置系统环境变量 PATH
- ubuntu 设置系统环境变量
- 通过环境变量设置将外部参数传递到qooxdoo应用系统内部
- 因未设置系统环境变量ORACLE_SID导致ORA-12162错误