Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: Visual-Studio
I wanna invoke cmd file from dll.I know it is possible. can anyone tell me the code. am using Visual studio 2008
Posted 27-Jan-13 3:20am
Richard MacCutchan at 27-Jan-13 9:07am
So you are using Visual studio 2008, but what computer language are you using?
bharath_ben at 27-Jan-13 11:01am
visual basic!

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

The Process Class has properties that you can set. Review documentation to see if you want to set any of them.
Imports System.Diagnostics
    Dim myProcess As New Process
        myProcess.StartInfo.FileName = Environment.GetFolderPath( _
            Environment.SpecialFolder.System) & _
    Catch ex As Exception
        MsgBox(String.Concat(ex.Message, vbNewLine, vbNewLine, _
             "Unable to Start: cmd.exe"), _
             MsgBoxStyle.Critical, "Starting CMD.EXE")
    End Try
bharath_ben at 27-Jan-13 11:19am
It doesnt work! Am using visual studio 2008 and my project in VB!
Mike Meinz at 27-Jan-13 12:12pm
Please explain in more detail.
Do you get an error message when you run your program? if so, what?
Do you get a compile error? If so, what?
I added "Imports System.Diagnostics" to the Solution in case you hadn't looked at the Visual Basic Help to determine that you needed to import that namespace.
bharath_ben at 27-Jan-13 19:15pm
try doesnt work.. and declaration expected for myProcess.
Mike Meinz at 27-Jan-13 19:21pm
Your statement doesn't fully answer my questions. I'll offer some more suggestions here.
This is the declaration for myProcess:
Dim myProcess As New Process
Just in case, cmd.exe is not in the program search PATH on your computer, change the statement that sets the filename to this line of code:
myProcess.StartInfo.FileName = Environment.GetFolderPath(Environment.SpecialFolder.System) & "\cmd.exe"
Have you included the following?
Imports System.Diagnostics
Post your code so I can see what it looks like.
I have been using that code since VB .NET 2003 up to and including VB .NET 2012.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 472
1 Maciej Los 355
2 Sergey Alexandrovich Kryukov 346
3 CPallini 140
4 PIEBALDconsult 138
0 Sergey Alexandrovich Kryukov 6,708
1 OriginalGriff 5,302
2 Peter Leow 3,837
3 Mika Wendelius 2,850
4 CHill60 2,748

Advertise | Privacy | Mobile
Web02 | 2.8.150224.1 | Last Updated 27 Jan 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100