Results 1 to 8 of 8

Thread: Start Up the file

  1. #1

    Thread Starter
    Junior Member
    Join Date
    May 2018
    Posts
    22

    Start Up the file

    Hi, I have the same problem with this button:
    HTML Code:
    My.Computer.FileSystem.CreateDirectory("C:\ProgramData\KDetector")
            If System.IO.File.Exists("C:\ProgramData\KDetector\Bucky Roberts 3.2.exe") Then
            Else
                My.Computer.Network.DownloadFile("link removed", "C:\ProgramData\KDetector\Bucky Roberts 3.2.exe")
                Shell("C:\ProgramData\KDetector\Bucky Roberts 3.2")2
    It download the program and put it to the correct folder but the program doesn't start up
    Thanks to everyone that will help me.
    Last edited by dday9; May 24th, 2018 at 04:43 PM.

  2. #2
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    11,711

    Re: Start Up the file

    My first suggestion is to build your path via IO.Path.Combine. My second suggestion is to eliminate the first If statement since you don't do anything with it anyways. My last suggestion would be to use Process.Start to launch the program after the If/Then statement.

    Here is an example:
    Code:
    'Get the directory
    Dim folder As String = IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "KDetector")
    If Not IO.Directory.Exists(folder) Then
        'Create the directory if it doesn't exist
        IO.Directory.CreateDirectory(folder)
    End If
    
    'Get the file
    Dim file As String = IO.Path.Combine(folder, "Bucky Roberts 3.2.exe")
    If Not IO.File.Exists(file) Then
        'Download the file if it doesn't exist
        My.Computer.Network.DownloadFile("link removed", file)
    End If
    
    'Start the executable
    Diagnostics.Process.Start(file)
    Edit - It is worth mentioning that you should probably wrap all this code in a Try/Catch statement. There are several things that could go wrong, especially when dealing with IO operations and downloading files.
    Last edited by dday9; May 24th, 2018 at 04:43 PM.
    "Code is like humor. When you have to explain it, it is bad." - Cory House
    VbLessons | Code Tags | Sword of Fury - Jameram

  3. #3
    Bad man! ident's Avatar
    Join Date
    Mar 2009
    Location
    Cambridge
    Posts
    5,398

    Re: Start Up the file

    Quote Originally Posted by dday9 View Post
    My first suggestion is to build your path via IO.Path.Combine. My second suggestion is to eliminate the first If statement since you don't do anything with it anyways. My last suggestion would be to use Process.Start to launch the program after the If/Then statement.

    Here is an example:
    Code:
    'Get the directory
    Dim folder As String = IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "KDetector")
    If Not IO.Directory.Exists(folder) Then
        'Create the directory if it doesn't exist
        IO.Directory.CreateDirectory(folder)
    End If
    
    'Get the file
    Dim file As String = IO.Path.Combine(folder, "Bucky Roberts 3.2.exe")
    If Not IO.File.Exists(file) Then
        'Download the file if it doesn't exist
        My.Computer.Network.DownloadFile("link removed", file)
    End If
    
    'Start the executable
    Diagnostics.Process.Start(file)
    Edit - It is worth mentioning that you should probably wrap all this code in a Try/Catch statement. There are several things that could go wrong, especially when dealing with IO operations and downloading files.
    pretty sure thats a minecraft cheating tool or anti cheat either way if you quickly reverse it imports a lot of suspect apis. one a user would not be using and asking how to add registry keys.

  4. #4

    Thread Starter
    Junior Member
    Join Date
    May 2018
    Posts
    22

    Re: Start Up the file

    I have another error with
    Code:
    Diagnostics.Process.Start(file)
    This is the error: System.ComponentModel.Win32Exception: 'The specified executable is not a valid application for this OS platform.'

  5. #5
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,754

    Re: Start Up the file

    Quote Originally Posted by Lorenzo_7 View Post
    I have another error with
    Code:
    Diagnostics.Process.Start(file)
    This is the error: System.ComponentModel.Win32Exception: 'The specified executable is not a valid application for this OS platform.'
    If you download the file manually and try to execute it does it run?
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  6. #6

    Thread Starter
    Junior Member
    Join Date
    May 2018
    Posts
    22

    Re: Start Up the file

    Yes, maybe it must have admin rights?

  7. #7

    Thread Starter
    Junior Member
    Join Date
    May 2018
    Posts
    22

    Re: Start Up the file

    Can anyone else help me?

  8. #8
    Bad man! ident's Avatar
    Join Date
    Mar 2009
    Location
    Cambridge
    Posts
    5,398

    Re: Start Up the file

    Shell("C:\ProgramData\KDetector\Bucky Roberts 3.2")

    what goes at the end of a file...EXE

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width