Skocz do zawartości
  • 👋 Witaj na MPCForum!

    Przeglądasz forum jako gość, co oznacza, że wiele świetnych funkcji jest jeszcze przed Tobą! 😎

    • Pełny dostęp do działów i ukrytych treści
    • Możliwość pisania i odpowiadania w tematach
    • System prywatnych wiadomości
    • Zbieranie reputacji i rozwijanie swojego profilu
    • Członkostwo w jednej z największych społeczności graczy

    👉 Dołączenie zajmie Ci mniej niż minutę – a zyskasz znacznie więcej!

    Zarejestruj się teraz
  • 0

Otwieranie innej aplikacji przyciskiem


kripciak

Pytanie

Opublikowano

Witam.

Mam pewien problem z moją aplikacją w vb.net

Chodzi o to że stworzyłem przycisk, którym chcę otworzyć grę, jednak po jego naciśnięciu wyskakuje mi "File not found",

chociaż podany plik znajduje się w folderze razem  z pisaną przeze mnie aplikacją.

Oto kod:

Imports System.Net
Imports System.IO

Public Class Form1
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Shell("config.exe")
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Shell("Metin2Client.exe")
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Button2.Enabled = False
        Dim request As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create("http://tavernmt2.tk/update/latest.txt")
        Dim response As System.Net.HttpWebResponse = request.GetResponse()
        Dim sr As System.IO.StreamReader = New System.IO.StreamReader(response.GetResponseStream())
        Dim newestversion As String = sr.ReadToEnd()
        Dim currentversion As String = Application.ProductVersion
        If newestversion.Contains(currentversion) Then
            Button2.Enabled = True
        Else
            Dim client As WebClient = New WebClient
            AddHandler client.DownloadProgressChanged, AddressOf client_ProgressChanged
            AddHandler client.DownloadFileCompleted, AddressOf client_DownloadCompleted
            client.DownloadFileAsync(New Uri("http://tavernmt2.tk/update/latest.exe"), Directory.GetCurrentDirectory & "/latest.exe")
        End If

    End Sub
    Private Sub client_ProgressChanged(ByVal sender As Object, ByVal e As DownloadProgressChangedEventArgs)
        Dim bytesIn As Double = Double.Parse(e.BytesReceived.ToString())
        Dim totalBytes As Double = Double.Parse(e.TotalBytesToReceive.ToString())
        Dim percentage As Double = bytesIn / totalBytes * 100
        ProgressBar1.Value = Int32.Parse(Math.Truncate(percentage).ToString())
        Label1.Text = "Pobrano " & percentage & "%"
    End Sub

    Private Sub client_DownloadCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.AsyncCompletedEventArgs)
        ProgressBar1.Value = 0
        Shell(Directory.GetCurrentDirectory & "/latest.exe")
        End
    End Sub



End Class

Dodam że przycisk otwierający config.exe działa bez zarzutu.

Screen z folderu gdzie uruchamiam aplikacje:

3329onk.png

1 odpowiedź na to pytanie

Rekomendowane odpowiedzi

Opublikowano

spróbuj 

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Shell("start Metin2Client.exe")
    End Sub

nie jestem pewien czy to zadziała, ale spróbuj

ALBO 

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Shell("Metin2Client")
    End Sub

ALBO 

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Shell("start Metin2Client")
    End Sub

sygna.png

Zarchiwizowany

Ten temat przebywa obecnie w archiwum. Dodawanie nowych odpowiedzi zostało zablokowane.

×
×
  • Dodaj nową pozycję...