Click here to Skip to main content
Rate this: bad
good
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 2:20am
Comments
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
good
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
    Try
        myProcess.StartInfo.FileName = Environment.GetFolderPath( _
            Environment.SpecialFolder.System) & _
            "\cmd.exe"
        myProcess.Start()
    Catch ex As Exception
        MsgBox(String.Concat(ex.Message, vbNewLine, vbNewLine, _
             "Unable to Start: cmd.exe"), _
             MsgBoxStyle.Critical, "Starting CMD.EXE")
    End Try
  Permalink  
v7
Comments
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 Sergey Alexandrovich Kryukov 620
1 CPallini 140
2 CHill60 130
3 ashok rathod 119
4 BillWoodruff 115
0 Sergey Alexandrovich Kryukov 9,543
1 OriginalGriff 6,984
2 CPallini 5,820
3 George Jonsson 4,017
4 Gihan Liyanage 3,266


Advertise | Privacy | Mobile
Web02 | 2.8.140926.1 | Last Updated 27 Jan 2013
Copyright © CodeProject, 1999-2014
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