Design a site like this with
Get started

Expect for .NET

Expect for .NET is a .NET library which ports of expect scripts functionality. The library is distributed under The MIT License.

Source code can be found on GitHub:

The latest version is available on NuGet:

Tutorial how to use Expect for .NET:

List of blog posts about Expect for .NET:


10 responses to “Expect for .NET”

  1. Hi, I’m trying your .dll from VB. It has a few issues because, for example, some functions like “send” are defined multiple times in spawn.cs. So from VB I get this error when trying to use it: Can you do something? 😉 Cheers, Michel


    1. Hi!
      Sure. I can release version 2.0.0 with removed case sensitive problems. I wasn’t aware that VB is not case-sensitive 😮

      Could you send me some code example in VB (something simple like spawning cmd.exe and sending command ‘dir’) so I can test it before release?



      1. Hi,

        The code below is enough to see the issue. It complains that “send” is ambiguous because declared more than once. The same wouuld happen with “expect” if I was trying to use it!

        Thanks, Michel

        Imports Expect

        Module TestExpect

        Sub Main()
            Dim MyExpect As New Expect.SpawnCommand("cmd.exe")
            MyExpect.send("Dir C:\" & vbCrLf)
        End Sub

        End Module


      2. Thanks for example. I’m currently working on the 2.0 version where this issue will be addressed.


      3. Version 2.0.0-beta was released:
        please give it try and let me know if it works for you.


      4. Thank for this new version. It seems to be working fine.
        I’ve no more immediate need for it… (!), but I’m sure the need will come back with another project one of these days!


  2. Hello!
    Is it possible to just attach Expect to any process? If I do so like
    Process proc = Process.Start(“cmd.exe”);

    ISession session = Expect.Expect.Spawn(new Expect.ProcessSpawnable(server));

    It creates new instance of cmd.exe…
    Thank you!


    1. ISession session = Expect.Expect.Spawn(new Expect.ProcessSpawnable(proc));

      Sorry, my mistake 😀


  3. Ok, solved 😀 Sorry for spamming.
    Process proc = new Process();
    proc.StartInfo = new ProcessStartInfo(“cmd.exe”);

    ISession session = Expect.Expect.Spawn(new Expect.ProcessSpawnable(proc));


    1. Hi Tom,

      Great to see that you found solution.

      And great to see that someone is using my work 😉

      Thanks for comments!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s