[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.)
:check: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
:down: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.
:down: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.
:down: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. :wave:
:down:Not yet answered. :check:Answered.
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).
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.
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.
Re: A Couple of Problems with My Application!
Thanks for the reply!, I'll try it now :)
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
Re: A Couple of Problems with My Application!
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
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.
Re: A Couple of Problems with My Application!