How mark Scripting.FileSystemObject as safe for scripting?

故事扮演 提交于 2021-01-27 20:32:16

问题


Introduction:

I'm programing a CNC machine. To be exact a Rover from Biesse. The editor from the software that is used to programing support VBScript. VBScript is used for implementing conditional statments and loops etc. In instruction to the software i have listed all syntax from VBScript marked as not to be used to avoid complication :)

Of course I would like to use VBScript :) To be exact - to open txt file and set up program base on the content.

The main problem: All the syntax of the VBScript is valid e.g.:

Dim dic
Set dic = CreateInstance("Scripting.Dictionary")

compiles, but:

Dim fso
Set fso = CreateInstance("Scripting.FileSystemObject")

throws error/exepction:

ActiveX component can't create object: 'Scripting.FileSystemObject'

I tried and checked many solution connected to unregistered dlls etc. All seems valid and be ok. Also i checked a simple script .wsf

<package>
<job>
<script language="VBScript">
set fso = CreateObject("Scripting.FileSystemObject")
set fout = fso.CreateTextFile("c:\BiesseMacros\RemoteTest.txt", true)
fout.WriteLine Now
fout.Close
</script>
</job>
</package>

It compiles and works. the situation is same on 4-5 different PC.

It all seems to be connected to the software not accepting components not marked as Safe for Scripting and Initialization ? Is it possible? I think it is something what is set up in project of application. App is on computer that won't connect to the internet, works on Windows XP. I know it is a bad idea to mark this component as safe, but i really want to. It will save me a couple of months of work (and life ;).

The question:

Is it possible and how to mark Scripting.FileSystemObject as Safe For Scripting?


回答1:


This link helped me out. In my case, I had to only create the key in registry

"Implemented Categories"

in HKCR\CLSID\"id's Scripting.FileSystemObject"

In this key i created same key as Scripting.Dictionary has:

and Voila!

Software recognize this object as safe.

Be advice!:

It can be harmful for your system - because it should not be marked as safe. In this way some pages could use the object without notification to manipulate your files! It is working for me - because the PC has no internet connection and that was the only way to trick the 3rd party software to use this object!



来源:https://stackoverflow.com/questions/41763974/how-mark-scripting-filesystemobject-as-safe-for-scripting

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!