我可以在 vbscript WSH 脚本中选择环境变量吗? [英] Can I pick up environment variables in vbscript WSH script?

查看:25
本文介绍了我可以在 vbscript WSH 脚本中选择环境变量吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在 Windows Scripting Host (WSH) VBS 脚本中读取系统环境变量?

Is is possible to read system environment variables in a Windows Scripting Host (WSH) VBS script?

(我正在使用 Windows Scripting Host 为 Cruise Control 任务编写 VBScript,并且想要获取项目构建 URL.)

(I am writing a VBScript using Windows Scripting Host for task for a Cruise Control and want to pick up the project build URL.)

推荐答案

这是一个例子(取自 这里):

Here's an example (taken from here):

Set oShell = CreateObject( "WScript.Shell" )
user=oShell.ExpandEnvironmentStrings("%UserName%")
comp=oShell.ExpandEnvironmentStrings("%ComputerName%")
WScript.Echo user & " " & comp

这篇关于我可以在 vbscript WSH 脚本中选择环境变量吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆