I want to obtain the errorlevel on an external file when execution of sql statements is done in cmd.exe so that I can proceed with my further coding.
I have used ECHO command and error level is displayed on the prompt,but i want to obtain it on an external file My code is like this;
Dim strCmdText As String
strCmdText = "/C sqlcmd -S " & Server & " -d " & Databasename & " -i " & FileName & " -o " & ResultFile & " -V "
System.Diagnostics.Process.Start("CMD.exe", strCmdText)
here output is returned in Resultfile,likewise i want to return the errorlevel.
If using the echo command prompts it for you why not use
@echo message> c:\test.txt
Also u can use
if errorlevel 1 goto function
:Function
@echo message> c:\test.txt
I think this is what you want? Instead of output maybe use the echo command to write to the file instead?