Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4087854
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T18:54:28+00:00 2026-05-20T18:54:28+00:00

I have a script CustomAction (Yes, I know all about the opinions that say

  • 0

I have a script CustomAction (Yes, I know all about the opinions that say don’t use script CustomActions. I have a different opinion.)

I’d like to run a command, and capture the output. I can do this using the WScript.Shell COM object, then invoking shell.Exec(). But, this flashes a visible console window for the executed command.

To avoid that, I understand I can use the shell.Run() call, and specify “hidden” for the window appearance. But .Run() doesn’t give me access to the StdOut of the executed process, so that means I’d need to create a temporary file and redirect the exe output to the temp file, then later read that temp file in script.

Some questions:

  • is this gonna work?

  • How do I generate a name for the temporary file? In .NET I could use a static method in the System.IO namespace, but I am using script here. I need to insure that the use has RW access, and also that no anti-virus program is going to puke on this.

  • Better ideas? I am trying very hard to avoid C/C++.


I could avoid all this if there were a way to query websites in IIS7 from script, without resorting to the IIS6 Compatibility pack, without using .NET (Microsoft.Web.Administration.ServerManager), and without execing a process (appcmd list sites).
I already asked a separate question on that topic; any suggestions on that would also be appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T18:54:28+00:00Added an answer on May 20, 2026 at 6:54 pm

    Answering my own question…

    1. yes, this is going to work.

    2. Use the Scripting.FileSystemObject thing within Javascript. There’s a GetTempName() method that produces a file name suitable for temporary use, and a GetSpecialFolder() method that gets the location of the temp folder. There’s even a BuildPath() method to combine them.

    3. so far I don’t have any better ideas.

    Here’s the code I used:

    function GetWebSites_IIS7_B()
    {
        var ParseOneLine = function(oneLine) {
            ...regex parsing of output...
        };
    
        LogMessage("GetWebSites_IIS7_B() ENTER");
    
        var shell = new ActiveXObject("WScript.Shell");
        var fso = new ActiveXObject("Scripting.FileSystemObject");
        var tmpdir = fso.GetSpecialFolder(SpecialFolders.TemporaryFolder);
        var tmpFileName = fso.BuildPath(tmpdir, fso.GetTempName());
        var windir = fso.GetSpecialFolder(SpecialFolders.WindowsFolder);
        var appcmd = fso.BuildPath(windir,"system32\\inetsrv\\appcmd.exe") + " list sites";
    
        // use cmd.exe to redirect the output
        var rc = shell.Run("%comspec% /c " + appcmd + "> " + tmpFileName, WindowStyle.Hidden, true);
        // WindowStyle.Hidden == 0
        var ts = fso.OpenTextFile(tmpFileName, OpenMode.ForReading);
        var sites = [];
    
        // Read from the file and parse the results.
        while (!ts.AtEndOfStream) {
            var oneLine = ts.ReadLine();
            var line = ParseOneLine(oneLine);
            LogMessage("  site: " + line.name);
            sites.push(line);
        }
        ts.Close();
        fso.DeleteFile(tmpFileName);
    
        return sites;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.