惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Y
Y Combinator Blog
有赞技术团队
有赞技术团队
J
Java Code Geeks
H
Hackread – Cybersecurity News, Data Breaches, AI and More
美团技术团队
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Hugging Face - Blog
Hugging Face - Blog
人人都是产品经理
人人都是产品经理
酷 壳 – CoolShell
酷 壳 – CoolShell
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
C
Check Point Blog
博客园 - 【当耐特】
The GitHub Blog
The GitHub Blog
Recent Announcements
Recent Announcements
The Cloudflare Blog
Microsoft Azure Blog
Microsoft Azure Blog
腾讯CDC
Vercel News
Vercel News
IT之家
IT之家
MyScale Blog
MyScale Blog
博客园_首页
Martin Fowler
Martin Fowler
WordPress大学
WordPress大学
罗磊的独立博客

博客园 - 岁月长河

emacs. verilog mode guide, example Powershell cmdlet 正则表达式篇 之三(BRE和ERE区别)及ELISP ISP architecture considering AHB 总线笔记 English Dictionary site for ODE and OALD makefile the diference between include and import windows 工具命令 cmd python namespace shell cmd args ROE, ROC IP 链接及常用软件 vim 分屏 and command usages vim autocmd irun vcs option 记录 consonant combination
vmic environment
岁月长河 · 2019-03-27 · via 博客园 - 岁月长河

' fso判断环境变量添加脚本是否存在
Set fso = CreateObject("Scripting.FileSystemObject")
' 以管理员权限运行环境变量添加脚本
Set UAC = CreateObject("Shell.Application")
tmpFile = ".\addToPath.bat"
If fso.FileExists(tmpFile) Then
UAC.ShellExecute ".\addToPath.bat", "", "", "runas", 1
Else
' 文件缺失,生成环境变量添加脚本
Set batFile = fso.CreateTextFile(".\addToPath.bat", True)
batFile.WriteLine("@echo off")
batFile.WriteLine(":: 获取当前文件夹绝对路径")
batFile.WriteLine("set tmpDir=%~dp0")
batFile.WriteLine("wmic ENVIRONMENT where " & chr(34) & "name='PATH' and username='<system>'" & chr(34) & " set VariableValue=" & chr(34) & "%tmpDir%;%PATH%" & chr(34))
UAC.ShellExecute ".\addToPath.bat", "", "", "runas", 1
End If
MsgBox "已将当前路径添加到环境变量PATH中", vbOkOnly+vbInformation,"操作完成"