- 1 year ago
Get javascript filepath in Windows Script Host
Comment
1 / 1
In Windows Script Host (WSH), you can use the WScript.ScriptFullName
property to get the full path of the currently executing script. However, please note that this property is only available in script files executed directly by the Windows Script Host, such as .vbs
or .js
files.
Here's an example of how you can retrieve the script file path using JavaScript in Windows Script Host:
javascriptvar scriptFilePath = WScript.ScriptFullName;
WScript.Echo("Script File Path: " + scriptFilePath);
Save the above code in a .js
file and execute it using Windows Script Host. It will display the full path of the script file in a message box.
Please ensure that you execute the script using Windows Script Host and not through a web browser or any other JavaScript runtime environment, as the WScript
object is specific to Windows Script Host.