Help with file path

CoachBarker

Well-known member
Joined
Jul 26, 2007
Messages
133
Programming Experience
1-3
We have come up with this to Launch and run the VPN and it works on the desktops at work with no problems

VB.NET:
Private Sub RunProg()
        Try
            Dim prc As New Process
            Dim desktopPath As String = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory)
            MsgBox(desktopPath)
            prc = Process.Start(desktopPath & "Shortcut to Syracuse University VPN.lnk")
            'Alt+Tab to make the VPN window appear on top
            Windows.Forms.SendKeys.Send("%")
            Windows.Forms.SendKeys.Send("{TAB}")
        Catch ex As Exception
            'MessageBox.Show("An error occured in frmMain  Method: RunProg(). Error: " & ex.Message)
            MsgBox("Error" & ex.ToString)
        End Try
    End Sub

But when I run it on my laptop at home to test the application off the domain I get this error

ErrorSystem.ComponentModel.Win32Exception: The system cannot find the file Specified
At System.Diagnostics.Process.StartWithShellExecuteEx (ProcessStartInfo startInfo)
At System.Diagnostics.Process.Start( )
At System.Diagnostics.Process.Start(ProcessStartInfo startInfo)
At System.Diagnostics.Process.Start(String fileName)
At BalantineProject3.frmMain.RunProg( ) in C:\Documents and Settings\barker44\Destop\Whitman Remote Desktop\BalantineProject3\Forms\frmMain,vb:ine 303

But if I run it this way on my laptop it works

VB.NET:
Private Sub RunProg()
        Try
            Dim prc As New Process
            prc = Process.Start("C:\Documents and Settings\All Users\Desktop\Shortcut to Syracuse University VPN.lnk")

            'Alt+Tab to make the VPN window appear on top
            Windows.Forms.SendKeys.Send("%")
            Windows.Forms.SendKeys.Send("{TAB}")
        Catch ex As Exception
            'MessageBox.Show("An error occured in frmMain  Method: RunProg(). Error: " & ex.Message)
            MsgBox("Error" & ex.ToString)
        End Try
    End Sub

Somehow we need to change it so the path is set to All Users and not Barker44. Does anyone have any suggestions?

Thanks once again
CoachBarker
 
Well hopefully this resolved the issue, will find out at work on Monday, it works at home on my laptop and on our desktop.

VB.NET:
Private Sub RunProg()
        Try
            '*************************************************************************************************
            Dim prc As New Process
            Dim ext As String = "All Users\Desktop\Shortcut to Big East University VPN.lnk"
            Dim desktopPath As String = My.Computer.FileSystem.SpecialDirectories.Desktop
            '*************************************************************************************************
            desktopPath = IO.Path.GetDirectoryName(desktopPath)
            desktopPath = IO.Path.GetDirectoryName(desktopPath)
            desktopPath = IO.Path.Combine(desktopPath, ext)
            '*************************************************************************************************
            'MsgBox(desktopPath)
            prc = Process.Start(desktopPath, ext)
            '*************************************************************************************************
            'Alt+Tab to make the VPN window appear on top
            Windows.Forms.SendKeys.Send("%")
            Windows.Forms.SendKeys.Send("{TAB}")
        Catch ex As Exception
            MsgBox("Error" & ex.ToString)
        End Try
    End Sub

Thanks for all the help
CoachBarker
 
Back
Top