Sign in with
Sign up | Sign in
Your question

Xcopy problems..

Last response: in Windows 7
Share
June 16, 2011 1:20:34 AM

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?

More about : xcopy problems

June 16, 2011 3:55:14 AM

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
June 16, 2011 10:18:46 AM

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..
Related resources
June 16, 2011 12:28:00 PM

Makes sense, here:

copy "C:\run.bat" "C:\Users\%username%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\run.bat" /y
June 22, 2011 12:09:55 PM

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?
June 22, 2011 7:45:59 PM

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.
June 23, 2011 5:04:38 AM

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?

Quote:

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
June 28, 2011 1:58:24 PM

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.
June 29, 2011 1:11:43 AM

Wait, so you want the computer to shut down as soon as it starts up? That wouldn't be very nice...
July 1, 2011 6:33:43 AM

Haha I know it wouldn't :p 
I can fix it in the startup, and its just to send to my nerdy friends :p 
!