EmEditor 的 JS 脚本能读写文件吗?

EmEditor 自带的几个宏脚本用一个奇怪的 ActiveXObject 对象操作文件,查MDN没找到,一搜居然是JScript 里面的,可文档里也没查到怎么读写文件。我印象里 JS 是不能对文件读写的,有熟悉的朋友知道 EmEditor 的 JS 脚本能否读写文件吗?谢谢!

1 Like

you may also search “FileSystemObject” for more references

1 Like

For more information, below is part of EmEditor’s online help document:

Windows Scripting Host

EmEditor macros are based on the Windows Scripting Host (WSH) engine, so you can use various Windows Component Object Model (COM) objects. For example, you can perform regular expression searches using the RegExp object, manipulate files using the FileSystemObject object, create a short-cut, manipulate the Windows Registry using the WshShell object, or work with networking functions using the WshNetwork object.

1 Like

It’s difficult to imagine it’s based on such a system. Thank you for sharing!

Clearly you are an expert on this topic. Another question: if Python is used as the scripting language as suggested in the doc, is it possble to simply use Python api for manipulating files? Thanks!

Not familiar with Python, but WSH would accept any language once the corresponding engine is installed, and according to the above link, pywin32 is what you need:

You may give it a try.
BTW, I’m not an expert at all.

1 Like

Thank you for your reply! WSH seems to be a system with long history. Is it still actively used and worthwhile to spend some time to be acquainted with?

My pleasure. Although it’s not widely used, Windows and Office use certain WSH script files (slmgr.vbs and ospp.vbs) to manipulate their activation systems, so you can find WSH really useful once you want to use COM in your scripts.

1 Like

OK. Great thanks for your patient explanation!

You’re welcome

1 Like