where you say Username you mean to write the username right?
Because I want it to work on many computers (all with different usernames)
So I'm really not sure what to do..
Even when I replace AppData with %AppData% it doesn't work..
Ok, new problem..
I want to do it from inside VB without the external batch file..
and I have to type:
Process.Start "cmd.exe" "/C xcopy "C:\run.bat" "C:\Users\%username%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\run.bat" /y"
but the problem is, it thinks im closing the wrong things..
Like it things this is what I'm closing..
"/C xcopy " and then C:\run.bat isn't enclosed in the marks, and then " " is the next one..
Well I think you get the point.. any ideas on what I can do?
I wouldn't use VB to launch the command prompt and issue the command, VB.NET can do what you want directly. I will send you the code when I get home from work. It will probably just be a couple of lines.
This should work. You can call it with a button by putting "CopyFile" in your button_click code. Or you could just put all the code within the sub directly into the button if you would like.
If you don't mind me asking, what are you intending your batch file to do?
Private Sub CopyFile()
'Get the current users startup path. It will look like this:
'C:\Users\*Current User*\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
Dim strStartupFolder As String = System.Environment.GetFolderPath(Environment.SpecialFolder.Startup)
'The destination for the batch file. It will look like this:
'C:\Users\*Current User*\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\run.bat
Dim strDestination As String = strStartupFolder & "\run.bat"
'The file to copy
Dim strFileToCopy As String = "C:\run.bat"
'If the file does not already exist, copy the batch file to the startup path
If File.Exists(strDestination) = False Then