Sign in to follow this  
Matt

Simple copy Command

Recommended Posts

Batch.

Can anyone explain to my why this doesnt work?

if not exist %windir%\system32\process.exe copy process.exe %windir%\system32\

Thanks so much!

Matt

Share this post


Link to post
Share on other sites

Doh! Ifigured it out. I wasn't in the same directory as process.exe when I was telling it to be copied. Therefor, it couldn't find the file :wacko:

Share this post


Link to post
Share on other sites

I am not getting that error When I use that syntax. I do think that you do need to use quotes

try these two examples

dir %userprofile%\desktop

and this

dir "%userprofile%\desktop"

Share this post


Link to post
Share on other sites

because %userprofile% expands to "C:\documents and settings\owner" (it may have a different user name). because of the spaces in "documents and settings" you need to enclose it in quotes

Share this post


Link to post
Share on other sites

think of it this way. the copy command needs two arguments. The first one is the file you are going to copy, the second is the destination to copy it two. CMD.exe splits the arguments up with spaces. So it is kind of like this, you used 4 arguments

copy(command)  test.txt(first argument)  C:\documents(second argument)  and(third argument)  settings\desktop(fourth argument)

by using quotes you have just two arguments

copy(command)  test.txt(first argument)  "C:\documents and settings\desktop"(second argument)

Edited by shanenin

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this