Click here to Skip to main content
16,007,885 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.
JavaScript
var shellActiveXObject = new ActiveXObject("Scripting.FileSystemObject");        
alert(shellActiveXObject.FileExists('C:/Windows/notepad.exe'))

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?
Posted

1 solution

I used Wscript.Shell and used it's ExpandEnvironmentStrings method.
JavaScript
var objshell = new ActiveXObject("Wscript.Shell");
var strfolderpath = objshell.ExpandEnvironmentStrings("%windir%");

It expanded it correctly
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900