Xcopy problems..

xcopy "C:\run.bat" "AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\" /y /i

That is what I've got..
But instead of copying 'run.bat' to the Startup folder.. it copies "AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\" to the C: drive..
What have I done wrong?
9 answers Last reply
More about xcopy problems
  1. I got it to work like this:

    copy "C:\run.bat" "C:\Users\username\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\run.bat" /y
  2. 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..
  3. Makes sense, here:

    copy "C:\run.bat" "C:\Users\%username%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\run.bat" /y
  4. 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?
  5. 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.
  6. 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
    File.Copy(strFileToCopy, strDestination)
    End If

    End Sub
  7. Thanks heaps I'll try it tomorrow :)
    I just want the batch file to shutdown their computer and add that same batch to their startup.
  8. Wait, so you want the computer to shut down as soon as it starts up? That wouldn't be very nice...
  9. Haha I know it wouldn't :P
    I can fix it in the startup, and its just to send to my nerdy friends :P
Ask a new question

Read More

Start Menu Microsoft Windows 7