Results 1 to 5 of 5

Thread: How to run a cmd command in a form application?

  1. #1

    Thread Starter
    New Member Farish's Avatar
    Join Date
    Oct 2013
    Location
    Male'
    Posts
    8

    How to run a cmd command in a form application?

    I've been trying to make a software that uses a cmd(command prompt) command. I don't know how I could, so I need some help. I want to know how can I run a cmd command in a form application?
    Thank you in advance to anyone who helps me

  2. #2
    New Member
    Join Date
    Apr 2012
    Posts
    6

    Re: How to run a cmd command in a form application?

    You can either use Process.Start or Shell function.
    For example:
    Shell("msg * Hello")

  3. #3
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,413

    Re: How to run a cmd command in a form application?

    Quote Originally Posted by Farish View Post
    I've been trying to make a software that uses a cmd(command prompt) command. I don't know how I could, so I need some help. I want to know how can I run a cmd command in a form application?
    Thank you in advance to anyone who helps me
    Depending which program you're trying to run in cmd, you can probably skip the command prompt completely and run the program in vb.net with process.start.
    I wouldn't recommend shell, as it's legacy code. the vb.net replacement is the process class.

  4. #4

    Thread Starter
    New Member Farish's Avatar
    Join Date
    Oct 2013
    Location
    Male'
    Posts
    8

    Re: How to run a cmd command in a form application?

    My program is simple. I have a text box it is to select a drive. And then I have a button this button is to start the progress.
    My cmd command is:
    Code:
     drive letter ( eg: G: ) ATTRIB -H -S -A *.* /S /D
    Also the command works in only administrator cmd.
    Thanks for your help.
    Can you give me an example of using process.start.

  5. #5
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,413

    Re: How to run a cmd command in a form application?

    here's a process.start example:

    http://msdn.microsoft.com/en-us/libr...v=vs.110).aspx

    the process' startinfo property has a verb property that you can set to "runas" for administrator privileges...

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width