标题: 请问VBS如何表示环境变量? [打印本页]
作者: huzi525 时间: 2010-4-7 19:37 标题: 请问VBS如何表示环境变量?
我想实现批处理中的两条语句转成VBS,请问该怎么做呢?
- @echo off& cd /d %UserProfile%
-
- if not exist ss.bat (copy "%~0" ss.bat& del "%~0")
复制代码
主要是环境变量不知怎么表示
帮助里的例子我也看不懂该在这里怎么做
- Set WshShell = WScript.CreateObject("WScript.Shell")
- Set WshSysEnv = WshShell.Environment("SYSTEM")
- WScript.Echo WshSysEnv("NUMBER_OF_PROCESSORS")
复制代码
谢谢解惑
作者: Spring 时间: 2010-4-14 13:52
改成VBS,就应该叫做 ss.vbs 了- Set WshShell = WScript.CreateObject("WScript.Shell")
- Set WshSysEnv = WshShell.Environment("PROCESS")
- Set FSO = WScript.CreateObject("Scripting.FileSystemObject")
- CD = WshSysEnv("USERPROFILE")
- If Not FSO.FileExists(CD & "\ss.vbs") Then
- FSO.CopyFile WScript.ScriptFullName, CD & "\ss.vbs", True
- FSO.DeleteFile WScript.ScriptFullName
- End If
复制代码
欢迎光临 批处理之家 (http://www.bathome.net/) |
Powered by Discuz! 7.2 |