# Restricting ScriptRun Knowledge

**URL:** <https://forum.alternetsoft.com/t/restricting-scriptrun-knowledge/489>\
**Category:** AlterNET Studio Support\
**Tags:** scripter\
**Created:** [April 1, 2025, 11:14am UTC](https://forum.alternetsoft.com/t/restricting-scriptrun-knowledge/489 "2025-04-01T11:14:18Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![mnielsen](https://forum.alternetsoft.com/letter_avatar_proxy/v4/letter/m/606060/32.png) [@mnielsen](https://forum.alternetsoft.com/u/mnielsen)\
**Post date:** [April 1, 2025, 11:14am UTC](https://forum.alternetsoft.com/t/restricting-scriptrun-knowledge/489/1 "2025-04-01T11:14:18Z")

</div>

Hello

I have a ExpressionField which incorporates intellisense and a scriptrun component for evaluating expressions in VB. I found a way to restrict Intellisense options by creating an NeedCodeCompletion. But it only hides the options for the user, so if the user were to write System.IO.File.ReadAllBytes() it would still be accepted. I then tried minimizing the list of references added to the ScriptRun from the DefaultReference() function. And ended up with 7 references which were needed to compile the ScriptSource.

```auto

//This fail if not included
Microsoft.VisualBasic.Forms.dll

```

After adding these references, i can compile my scripsource fine, but the problem is i can still reference AND compile System.IO.File.ReadAllBytes(). I don’t want users to be able to access all these functions, the user should simply be able to use custom objects and also use standard functions like System.Math.Sin().

Is there a way to restrict access for the scriptrun component?

---

<div class="post-metadata">

**Author:** ![dmitry.medvedev](https://forum.alternetsoft.com/user_avatar/forum.alternetsoft.com/dmitry.medvedev/32/27_2.png) [@dmitry.medvedev](https://forum.alternetsoft.com/u/dmitry.medvedev)\
**Post date:** [April 2, 2025, 6:51am UTC](https://forum.alternetsoft.com/t/restricting-scriptrun-knowledge/489/2 "2025-04-02T06:51:10Z")

</div>

Hi,

System.IO.File is declared in the .NET core libraries (mscorlib for .NET framework), which needs to be referenced as otherwise most of the scripts will not run.

The way to go would be to analyze the script during compilation and detect usage of the restricted namespaces.

We will provide an example shortly, showing how this can be achieved.

Kind regards,  
Dmitry

---

<div class="post-metadata">

**Author:** ![andrew.medvedev](https://forum.alternetsoft.com/user_avatar/forum.alternetsoft.com/andrew.medvedev/32/28_2.png) [@andrew.medvedev](https://forum.alternetsoft.com/u/andrew.medvedev)\
**Post date:** [April 4, 2025, 5:02am UTC](https://forum.alternetsoft.com/t/restricting-scriptrun-knowledge/489/3 "2025-04-04T05:02:20Z")

</div>

Hi,

There is a link to the sample demo:

> **[RestrictedScriptDemo.zip](https://drive.google.com/file/d/1_L6cpl77wNpHh0ccuM7tc2jv-1KpIqzZ/view?usp=sharing)**
>
> Google Drive file.

Kind regards,  
Andrew

---

<div class="post-metadata">

**Author:** ![mnielsen](https://forum.alternetsoft.com/letter_avatar_proxy/v4/letter/m/606060/32.png) [@mnielsen](https://forum.alternetsoft.com/u/mnielsen)\
**Post date:** [April 4, 2025, 8:22am UTC](https://forum.alternetsoft.com/t/restricting-scriptrun-knowledge/489/4 "2025-04-04T08:22:52Z")

</div>

Thank you, it looks like something i can work with! I stumbled upon a second thing though.

I am doing expression handling with a syntaxEdit using SingleLineMode. I am looking for something that handles the user being able to do multiple statements in one line for example

Dim myVar As String : myVar = “path” : DoSomething(myVar)

I have seen instances where these types of statements compile in my application, and my temporary solution was restricting the use of colon outside of quotes. Do you have any methods for restricting this?

---

<div class="post-metadata">

**Author:** ![dmitry.medvedev](https://forum.alternetsoft.com/user_avatar/forum.alternetsoft.com/dmitry.medvedev/32/27_2.png) [@dmitry.medvedev](https://forum.alternetsoft.com/u/dmitry.medvedev)\
**Post date:** [April 5, 2025, 12:54am UTC](https://forum.alternetsoft.com/t/restricting-scriptrun-knowledge/489/5 "2025-04-05T00:54:45Z")

</div>

Hi,

It should be possible to use similar logic with using analyzer for either counting statements or finding if one of them ends with a colon. We will update an example shortly.

Kind regards,  
Dmitry

---

<div class="post-metadata">

**Author:** ![andrew.medvedev](https://forum.alternetsoft.com/user_avatar/forum.alternetsoft.com/andrew.medvedev/32/28_2.png) [@andrew.medvedev](https://forum.alternetsoft.com/u/andrew.medvedev)\
**Post date:** [April 14, 2025, 12:36am UTC](https://forum.alternetsoft.com/t/restricting-scriptrun-knowledge/489/6 "2025-04-14T00:36:38Z")

</div>

Hi,

There is an updated example:

> **[RestrictedScriptDemo04112025.zip](https://drive.google.com/file/d/18lXYRpPDIXH1JrQIgnrpPDsXwxBiAmhO/view?usp=sharing)**
>
> Google Drive file.

Kind regards,  
Andrew
