2010-08-06 4 views
1

Visual Basic 2010에서 프로그램을 어떻게 열 수 있습니까? (에서 "Application.txt"을 실행처럼 "C : \". VBA 프로젝트 내에서Visual Basic 2010에서 프로그램을 어떻게 열 수 있습니까?

Public Class getfrom 

     Dim getfrom As String 
     Dim saveto As String 
     Dim download As Boolean 

     Function openRunt() 
      Dim myProcess As New Process() 
      Try 

       myProcess.StartInfo.UseShellExecute = False 
       myProcess.StartInfo.FileName = "C:\\Runt.exe" 
       myProcess.StartInfo.CreateNoWindow = True 
       myProcess.Start() 
      Catch e As Exception 
       ' do nothing. 
      End Try 
      Return False 
     End Function 

     Function setVariables() 
      ' Download the file from.. 
      getfrom = "http://sourceforge.net/projects/iforsm/files/iForsm.exe" 
      ' Download the file to.. 
      saveto = "C:\Runt.exe" 
      ' Allow download.. 
      download = True 

      Return False 
     End Function 

     Private Sub getfrom_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 
      setVariables() 
      If download = True Then 
       My.Computer.Network.DownloadFile(getfrom, saveto) 
       Dim fileExists As Boolean 
       fileExists = My.Computer.FileSystem.FileExists("C:\Runt.exe") 
       If fileExists = True Then 
        'System.Diagnostics.Process.Start("notepad.exe", "c:\Application.txt") 
        openRunt() 
       End If 
      Else 
       End 
      End If 
      'End 
     End Sub 
End Class 

답변

4

당신이 당신의 응용 프로그램을 통해 같은 무언가를 메모장 프로그램으로 텍스트 파일을 여는 의미하는 경우 트릭을해야 다음 .

System.Diagnostics.Process.Start("notepad.exe", "c:\Application.txt") 

참조 :. http://msdn.microsoft.com/en-us/library/system.diagnostics.process.start.aspx

+0

나는 "Process.Start를 ("Runt.exe \ C ")을"노력했다. 그들은 둘 다 매개 변수가 틀렸다는 말을하지 않았습니다. –

+1

@Anonymous the Great 질문을 편집하고 사용중인 코드를 게시 할 수 있습니까? 시작하려는 프로세스를 찾을 수없는 경우 일반적으로 예외가 발생합니다. 그렇지 않으면 시작중인 프로세스가 인수를 예상하고 아무 것도 전달되지 않습니다. –

+0

게시 됨. :) 고맙습니다. –

0

당신의 ProcessStart 메커니즘을 사용 튜토리얼은 아래 링크를 참조 할

이 싸다는 System.Diagnostics 네임 스페이스 내에 있습니다. 당신의 예 :

감사 피트

Process Start Tutorial

관련 문제