Link to home
Start Free TrialLog in
Avatar of karanpatel
karanpatel

asked on

setup problem with the console application

Hello
I've made an app which reads the reading from a weighing scale.

Everything seems to be working perfect. I made a setup file to deploy it to some other system, the setup is successfully deployed, but when i try opening the app from the menu, it says 'PATH NOT FOUND' and sometimes 'FILE NOT FOUND'. This error is thrown in the very begining of the start of the software. Possibly where i see the error is on the line where i'am allocating the console window to start 'AllocConsole'.

please give me a solution to this at the earliest as i need it on a very urgen basis, i'am pasting source code below.

----------------------------------------------------------Option Explicit

Private Declare Function AllocConsole Lib "kernel32" () As Long
Private Declare Function GetStdHandle Lib "kernel32" (ByVal nStdHandle As Long) As Long
Private Declare Function WriteConsole Lib "kernel32" Alias "WriteConsoleA" (ByVal hConsoleOutput As Long, ByVal lpBuffer As String, ByVal nNumberOfCharsToWrite As Long, lpNumberOfCharsWritten As Long, lpReserved As Any) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Declare Function FreeConsole Lib "kernel32" () As Long

Private Const STD_OUTPUT_HANDLE = -11&

Private hConsole As Long

Private Sub Command1_Click()
Dim app_name As String
Dim txt As String
Dim num_written As Long

    app_name = App.Path
    If Right$(app_name, 1) <> "\" Then app_name = app_name & "\"
    app_name = app_name & "test.bat"

    txt = "Ready to run" & vbCrLf
    WriteConsole hConsole, txt, Len(txt), num_written, vbNullString
    Shell app_name
End Sub
Private Sub Form_Load()
Dim txt As String
Dim num_written As Long

    If AllocConsole() Then
        hConsole = GetStdHandle(STD_OUTPUT_HANDLE)
        If hConsole = 0 Then MsgBox "Couldn't allocate STDOUT"

        ' Present a warning.
        txt = "******************************************" & vbCrLf & _
              "*   Warning: Do not close this window!   *" & vbCrLf & _
              "* Close the VB program's window instead. *" & vbCrLf & _
              "******************************************" & vbCrLf
        WriteConsole hConsole, txt, Len(txt), num_written, vbNullString

        ' Make this form visible and on top.
        Me.Show
        SetFocus
    Else
        MsgBox "Couldn't allocate console"
    End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
    CloseHandle hConsole
    FreeConsole
End Sub
----------------------------------------------------------

Please give me a soln to this at the earliest.


Avatar of mcbeth
mcbeth

seems to be a problem with test.bat
I think this file dosn't exists.

ASKER CERTIFIED SOLUTION
Avatar of TimCottee
TimCottee
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of DanRollins
Hi karanpatel,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Accept TimCottee's comment(s) as an answer.

karanpatel, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you.  DO NOT accept this comment as an answer.

EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
==========
DanRollins -- EE database cleanup volunteer
Per recommendation, force-accepted.

Netminder
CS Moderator