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

  • SEARCH
  • Home
  • 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 5948535
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T17:07:16+00:00 2026-05-22T17:07:16+00:00

Lets just say we have this as Command1 Dim Command1 = whoami.exe >> C:\Hello.Txt

  • 0

Lets just say we have this as Command1

Dim Command1 = "whoami.exe >> C:\Hello.Txt"

The program will read a list of users from a text file and then perform the action on each of them. If the user does not exist, or they are part of a password protected computer, I would like to see that in my printout.

I have this but am Unsure how to write the If Then Statement (If that is the ebst route to take)

For Each strUserName as String in strLines
Shell("cmd.exe /c" & Command1)
If Command1 = fail??
Then msgbox("Oops") ???
  • 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-22T17:07:17+00:00Added an answer on May 22, 2026 at 5:07 pm

    If you want to redirect the output of ‘whoami.exe’ to your own console, you can do the following:

    Dim startInfo As New ProcessStartInfo()
    startInfo.Arguments = "c:\Hello.txt"
    startInfo.FileName = "c:\whoami.exe"
    startInfo.RedirectStandardOutput = True
    startInfo.UseShellExecute = False
    
    Using process As Process = Process.Start(startInfo)
        Using stream As StreamReader = process.StandardOutput
            Console.Write(stream.ReadToEnd())
        End Using
    End Using
    

    You will need to import the System.Diagnostics namespace. If ‘whoami.exe’ returns an exit code you can use, you can also use the Process class to check it by calling:

    process.WaitForExit()
    Dim code As Integer = process.ExitCode
    If code = 1 Then
        ' success
    Else
        ' other
    End If
    

    Hope this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Lets say I have hierarchy like this (This is just a test program. Please
Lets just say that I have three textboxes: TextBox1, TextBox2, TextBox3. Normally if I
Lets say I have the string: MyNamespace.SubNameSpace.MyClassName How do I extract just everything after
just a question that needs a quick answer, I have a Action, lets say,
This is just a question to help me understand CSS rendering better. Lets say
Hi I read a few post on this topic, lets say I want to
So I have an object graph, let's just say it's an order. You have
Let's say I have css1.css and css2.css. Just for the sake of keeping files
Let's say: <div> pre text <div class=remove-just-this> <p>child foo</p> <p>child bar</p> nested text </div>
I have read this manual: http://git-scm.com/docs/gitignore As I am working with gitosis, I rather

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.