Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27248

Using VB 2010 Windows form on a win 7 computer - Crash in Shell instruction

$
0
0
What I want to do is run this program which is minimized in the task bar, and when it finishes processing, I want to start a new instance of my program which will also be minimized in the task bar and then End the current pgm which will leave the fresh version of my pgm running and minimized in the task bar.

I am getting an error message on the Shell instruction of "File not found".
I have verified that the pgm is really where I say it is in the Shell instruction.

What is wrong?? code below


Code:

Imports System
Imports System.Windows.Forms
Imports System.Security.Permissions

<PermissionSet(Security.Permissions.SecurityAction.Demand, Name:="FullTrust")> _
Public Class FormTransferDataRey

    Public Sub New()
        InitializeComponent()
    End Sub

    Private Response, ReturnValue As Double

    Private Sub FormTransferDataRey_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.CenterToParent()
    End Sub

    Private Sub ButtonXfer_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonXfer.Click
        Dim sKeys As String

        Try
            Beep()
            Response = MsgBox("Did you Click or Highlight the first ""Input Field"" prior to Clicking this button?", _
                              vbYesNo + vbExclamation)
            If Response = vbYes Then
                Me.WindowState = FormWindowState.Minimized

                ButtonXfer.Enabled = False
                My.Computer.Keyboard.SendKeys("{Enter}", True)

                sKeys = "Jones"
                Call SendTheseKeys(sKeys)
                sKeys = "John"
                Call SendTheseKeys(sKeys)
                sKeys = "Paul"
                Call SendTheseKeys(sKeys)

                My.Computer.Keyboard.SendKeys("{Enter}", True)

                sKeys = "215 Advantage lane"
                Call SendTheseKeys(sKeys)
               
                Beep()
                Call PlaySoundFile()
                ButtonXfer.Enabled = True

                ReturnValue = Shell("C:\Program Files\DEI Compile Output - DeiTransferDataRey\DeiTransferDataRey.application", AppWinStyle.MinimizedNoFocus, True, 1000)

                End
            Else
                Beep()
                MsgBox("Click the first ""Input Field"" now")
            End If

        Catch ex As Exception
            MsgBox("Error in ""TransferData"" : " + ex.Message)
        End Try
    End Sub
    '*********************************************************************

    Private Sub SendTheseKeys(ByRef skeys)
        skeys = UCase(skeys)
        My.Computer.Keyboard.SendKeys(skeys, True)
        My.Computer.Keyboard.SendKeys("{Enter}", True)
    End Sub
    '*********************************************************************

    Private Sub SendTheseKeysNoUcase(ByVal skeys)
        My.Computer.Keyboard.SendKeys(skeys, True)
        My.Computer.Keyboard.SendKeys("{Enter}", True)
    End Sub
    '*********************************************************************

    Private Sub PlaySoundFile()
        My.Computer.Audio.Play("C:\DEI Sounds\VerifyData.wav", AudioPlayMode.WaitToComplete)
    End Sub
    '*********************************************************************
End Class


Viewing all articles
Browse latest Browse all 27248

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>