Hello,
I have a program that when you press a button it maps 2 drives, updates a registry value and then starts a executable which is stored in a SQL table. I'm having issues after the file opens. The program it opens does not seem to be working quite right. When you open the program by clicking on the .exe it works file. When I call it from the app, I have issues with the program after it opens. Can someone explain to me the difference between double clicking an .exe and using process.start? Is there a different way to do it? My code is listed below.
Code:Imports System.Data.SqlClient
Imports System.Console
Imports System.Configuration
Imports System.Data
Imports System.IO.Directory
Imports System.Diagnostics
Imports Microsoft.Win32
Public Class Main
Private Sub butPds_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles butPds.Click
Dim objNetwork
Dim cmbValue As String
Dim SQLConn As New SqlConnection() 'The SQL Connection
Dim SQLCmd As New SqlCommand() 'The SQL Command
Dim strSQL As String
cmbValue = cmbProjectSel.Text
'Dim ConnString As New SqlConnection
SQLConn.ConnectionString = "Server=GRN2007;Database=VB_Projects;Trusted_Connection=True" 'Set the Connection String
strSQL = "SELECT PDS_Location,LS_Location, pd_configure, PDS_exe FROM vw_PDS_SPR_Locations WHERE project =" & "'" & cmbValue & "'"
Dim myCommand As New SqlCommand(strSQL, SQLConn)
SQLConn.Open() 'Open the connection
Dim myReader As SqlDataReader
Dim uncLocation As String = ""
Dim uncLocation1 As String = ""
Dim uncLocation2 As String = ""
Dim uncLocation3 As String = ""
Dim strDriveLetter1 As String
Dim strDriveLetter2 As String
myReader = myCommand.ExecuteReader()
While myReader.Read()
uncLocation = myReader(0).ToString()
uncLocation1 = myReader(1).ToString()
uncLocation2 = myReader(2).ToString()
uncLocation3 = myReader(3).ToString()
End While
objNetwork = CreateObject("WScript.Network")
'Section which unmaps the drives,
Try
objNetwork.RemoveNetworkDrive("F:", True, True)
objNetwork.RemoveNetworkDrive("G:", True, True)
Catch ex As Exception
End Try
strDriveLetter1 = "F:"
strDriveLetter2 = "G:"
' Section which maps the drives,
Try
objNetwork.MapNetworkDrive(strDriveLetter1, uncLocation, True)
objNetwork.MapNetworkDrive(strDriveLetter2, uncLocation1, True)
Catch ex As Exception
Try
My.Computer.Registry.SetValue("HKEY_LOCAL_MACHINE\Software\Intergraph\PD_SHELL\07.00\", "ControlFile", uncLocation2)
Catch ex As Exception
End Try
myReader.Close()
SQLConn.Close()
Dim startInfo As New ProcessStartInfo(uncLocation3)
startInfo.WindowStyle = ProcessWindowStyle.Hidden
startInfo.UseShellExecute = False
startInfo.WorkingDirectory = "C:\win32app\ingr\pdshell\bin\"
Process.Start(uncLocation3)
'Me.Close()
End Sub

