Results 1 to 10 of 10

Thread: [RESOLVED] A Couple of Problems with My Application!

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2010
    Posts
    8

    [RESOLVED] A Couple of Problems with My Application!

    Hi guys, I just have a few problems regarding my application, any suggestions would be great, thanks. (I'm quite new to this stuff, making an application(s) for fun haha.)

    1) I'm planning to distribute this application, but the problem is if I send it to another computer the user will most likely not be "Home2" and this code wouldn't work right?.
    Code:
            If (File.Exists("C:\Documents and Settings\Home2\Start Menu\Programs\Startup\example.exe")) = True Then
                File.SetAttributes("C:\Documents and Settings\Home2\Start Menu\Programs\Startup\example.exe", attribute)
            ElseIf (File.Exists("C:\Documents and Settings\Home2\Start Menu\Programs\Startup\example.exe")) = False Then
            End If
    2) How would I make this application download a file off a direct link?
    EX. Here's the direct link:
    http://download772.mediafire.com/jyz...ds_Country.jpg
    and uhm...I want it so if I open the application, it would automatically save this into my C:\Documents and Settings.

    3) Also..how would I make my application run on startup for a MacBook(Only used one once or twice..)? I'm currently putting the application in the startup folder as well as in "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\example", but these don't work for a MacBook I'm assuming.

    4) My last question is if the codes would cause any errors when my application is used in a Mac...Say for example this code:
    Code:
    Dim FileName As String
            Dim FilePath As Object
            Dim RegistryKey As Object
            FileName = "example.exe"
            FilePath = Path.GetFullPath(FileName)
            RegistryKey = CreateObject("WScript.Shell")
            RegistryKey.RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\example", FilePath)
    or maybe..
    Code:
    If (File.Exists("C:\WINDOWS\system32\drivers\etc\example.exe")) = False Then
                File.Copy(Application.ExecutablePath, "C:\WINDOWS\system32\drivers\etc\" & My.Application.Info.AssemblyName & ".exe")
            ElseIf (File.Exists("C:\WINDOWS\system32\drivers\etc\example.exe")) = True Then
            End If
    That's it I guess(for now lol), if you have any suggestions for me, please post them! Thanks.

    Not yet answered. Answered.
    Last edited by Bryvx; Apr 25th, 2010 at 05:41 PM.

  2. #2
    Frenzied Member
    Join Date
    Sep 2006
    Location
    Scotland
    Posts
    1,054

    Re: A Couple of Problems with My Application!

    1) To return the username, use this:

    Code:
    Mid(My.User.Name, InStr(My.User.Name, "\") + 1)
    This can then be put into the file path instead of "Home2".

    2) I am not entirely sure what you mean, but if it helps have a look at:

    Code:
    My.Computer.Network.DownloadFile(address As String, destinationFileName As String)
    3+4) A VB.NET application will not run on a mac (unless something has happened that I am unaware of).

  3. #3

    Thread Starter
    New Member
    Join Date
    Apr 2010
    Posts
    8

    Re: A Couple of Problems with My Application!

    Could u explaing how? I tried replacing "home2" with the code but it didnt work for me.

  4. #4
    Frenzied Member
    Join Date
    Sep 2006
    Location
    Scotland
    Posts
    1,054

    Re: A Couple of Problems with My Application!

    Quote Originally Posted by 03myersd
    Code:
    If (File.Exists("C:\Documents and Settings\" + Mid(My.User.Name, InStr(My.User.Name, "\") + 1) + "\Start Menu\Programs\Startup\example.exe")) = False Then
        File.Copy(Application.ExecutablePath, "C:\Documents and Settings\Home2\Start Menu\Programs\Startup\" & My.Application.Info.AssemblyName & ".exe")
    End If
    The above code should do it.

    Generally the best way to get help is to post it in the forums. It is normally the fastest way. I just happened to be online just now.
    From the PM I sent you just now. Just so that anyone else who has the problem can see the solution.
    Last edited by 03myersd; Apr 25th, 2010 at 05:37 PM. Reason: Fixed Code

  5. #5

    Thread Starter
    New Member
    Join Date
    Apr 2010
    Posts
    8

    Re: A Couple of Problems with My Application!

    Thanks for the reply!, I'll try it now

  6. #6

    Thread Starter
    New Member
    Join Date
    Apr 2010
    Posts
    8

    Re: A Couple of Problems with My Application!

    I still get an error lol,
    If (File.Exists("C:\Documents and Settings\" + Mid(My.User.Name, InStr(My.User.Name, "\") + 1)" + "\Start Menu\Programs\Startup\example.exe")) = False Then
    File.Copy(Application.ExecutablePath, "C:\Documents and Settings\Home2\Start Menu\Programs\Startup\" & My.Application.Info.AssemblyName & ".exe")
    End If

  7. #7
    Frenzied Member
    Join Date
    Sep 2006
    Location
    Scotland
    Posts
    1,054

    Re: A Couple of Problems with My Application!

    What error do you get?

  8. #8

    Thread Starter
    New Member
    Join Date
    Apr 2010
    Posts
    8

    Re: A Couple of Problems with My Application!

    nevermind i think i got it(there's an extra "), thanks! btw so this will work on other compuiters?
    (the copying part)
    File.Copy(Application.ExecutablePath, "C:\Documents and Settings\Home2\Start Menu\Programs\Startup\" & My.Application.Info.AssemblyName & ".exe")
    End If
    Last edited by Bryvx; Apr 25th, 2010 at 05:35 PM.

  9. #9
    Frenzied Member
    Join Date
    Sep 2006
    Location
    Scotland
    Posts
    1,054

    Re: A Couple of Problems with My Application!

    Oh yes. I see what I did now. And yes, it should work on other computers. If this thread is resolved, then if you could please mark it as so, using the thread tools option near the top of the page.

    Edit: Also make sure you fix the second line of code, using the same method as in the IF statement.

  10. #10

    Thread Starter
    New Member
    Join Date
    Apr 2010
    Posts
    8

    Re: A Couple of Problems with My Application!

    Alright, thanks alot.

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