WshShell.Exec output read impossible until command finished

Discussion in 'Scripting' started by V Poirot, Jun 21, 2009.

  1. V Poirot

    V Poirot Guest


    I've done a script to force remove of old DCs.
    I'm using NTDSUTIL command line tool for that, and it's working like I
    want, except under Windows 2008 (DC)!

    I'm unable to read output until command (ntdsutil) has exited. But it's not
    what I want, because other inputs depends on previous output.

    Question: How can I have a live output read (like under Windows 2003 DC)?
    or is their another way to force DC removal (by scripting)?

    Here is a sample of my script:

    Set WshShell = CreateObject("WScript.Shell")
    strCmd = "cmd /c ntdsutil ""popups off"" ""me c"" co ""co to se %
    computername%"" q ""se op ta"" ""list sites"""
    Set oExec = WshShell.Exec(strCmd)
    tmpline = ""
    While Not oExec.StdOut.AtEndOfStream
    tmpline = LCase(oExec.StdOut.ReadLine)

    ' some output analyse...
    ' and sometimes, I've to send new command, like this one:

    oExec.stdIn.WriteLine "select site " & siteSelection



    Thanks for your help
    V Poirot, Jun 21, 2009
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.