本文介绍了使用ActiveXObject Scripting.FileSystemObject使用环境变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用ActiveXObject,而我正在使用FileExists函数.我正在做一些测试,看是否有效.我终于能够显示正确.

Im using ActiveXObject and I am using the FileExists function. I was doing some testing to see if it worked. I finally was able to show true.

var shellActiveXObject = new ActiveXObject("Scripting.FileSystemObject");        
alert(shellActiveXObject.FileExists('C:/Windows/notepad.exe'))


我想用%windir%之类的环境变量替换C:/Windows.
当我这样做时,它会将其读取为false.


I want to replace the C:/Windows with an environment variable like %windir%.
When I do that, it reads it as false. How can I make it so it inteprets the environment variable?

推荐答案

var objshell = new ActiveXObject("Wscript.Shell");
var strfolderpath = objshell.ExpandEnvironmentStrings("%windir%");


它正确展开了


It expanded it correctly


这篇关于使用ActiveXObject Scripting.FileSystemObject使用环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-17 17:45