I am starting my vb.net console application .exe from within a batch file, such as this: (timeout used for test purposes)
@Echo off echo Starting Script start C:\Users\user\Desktop\ConsoleApplication2 timeout /t 8 /nobreak start C:\Users\user\Desktop\ConsoleApplication2 When the vb.net console application is run, a process name, description, date/time and computer name are passed in and inserted into the sql database. At the moment however, only the date/time (done in sql) and computer name are correct as they are done automatically, whereas the name and description would be user input. I have tried to use command line arguments for at least the name, but seeing as the vb application is running from the batch file, it didn't work. So now I am wondering if there is any other way I could get the Name and Description inputs (without altering the time/waiting for input as the timestamps are crucial) or if anyone had any suggestions?
VB.net code:
Imports System Imports System.Data Imports System.Data.SqlClient Imports Console = System.Console Module Module1 Sub Main() 'Connection to server Dim conn As New SqlClient.SqlConnection conn.ConnectionString = ("Server Connection Info...;") conn.Open() 'Calling Stored Procedure Dim objCommand As New SqlClient.SqlCommand objCommand.Connection = conn objCommand.CommandText = "ProcessLog_Insert" objCommand.CommandType = CommandType.StoredProcedure 'Pass in each of the required parameters objCommand.Parameters.Add("ProcessName", SqlDbType.NVarChar).Value = "Test3" 'Pass in a description of the process being run objCommand.Parameters.Add("ProcessDescription", SqlDbType.NVarChar).Value = "Desc" 'Pass in the Computer name used by current machine objCommand.Parameters.Add("ComputerName", SqlDbType.NVarChar).Value = Environment.MachineName 'Execute the Query objCommand.ExecuteNonQuery() 'Closes the Connection conn.Close() conn = Nothing objCommand = Nothing End Sub End Module