Visual Basic.NET - funcion shell(urgente)

 
Vista:

funcion shell(urgente)

Publicado por carla pamela (1 intervención) el 11/07/2007 19:05:21
hola a todos ayudenme cone esto
:

quiero ejecutar con la funcion
shell(D:\WindowsApplication2\WindowsApplication2\bin\Release\WindowsApplication2.exe)

lo que quiero es obtener esta direccion sin tener que cambiarla a cada rato ayudenme por favor gracias
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:funcion shell(urgente)

Publicado por QWNET (65 intervenciones) el 11/07/2007 23:17:52
Pues yo lo haria de esta manera...

If ExisteArchivo(apppath() & "WindowsApplication2.exe") Then
Dim spath As String, sexe As String, apppath As String, sfile As String
sfile = "WindowsApplication2.exe"
'saber el path donde se esta ejecutando el EXE
spath = System.Reflection.Assembly.GetExecutingAssembly.Location
sexe = Dir(spath)
'saca el path y el archivo que deseamos ejecutar
apppath = Microsoft.VisualBasic.Left(spath, Len(spath) - Len(sexe)) + sfile
'---------------------------------------------------------------------
Dim Proc As New System.Diagnostics.Process
Proc.StartInfo.FileName = apppath
Proc.Start()
'------------------------------------------------------------------
' o en su defecto si no se utiliza el PROC
shell(apppath)
Else
Mensaje("El archivo EXE no existe...")
End If

' sacar el path donde esta el EXE que vamos a ejecutar que debe de estar alojado
por supuesto donde esta el EXE primario.

Public Function AppPath() As String
'Devuelve el path del archivo .exe
Dim sPath As String, sExe As String

sPath = System.Reflection.Assembly.GetExecutingAssembly.Location
sExe = Dir(sPath)
AppPath = Left(sPath, Len(sPath) - Len(sExe))

End Function

' verificar si existe el EXE que deseamos ejecutar

Public Function ExisteArchivo(ByVal sNombreArchivo As String) As Boolean
Try
If Trim(sNombreArchivo) = "" Then
MensajeError("Nombre de archivo no válido")
Else
ExisteArchivo = Dir(sNombreArchivo) <> ""
End If
Catch ex As Exception
MensajeError(Err.Description)
End Try
End Function
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar