Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I have a batch file which doesnot want to run,what do I do wrong? 1

Status
Not open for further replies.

cgkeller

Programmer
Apr 12, 2000
200
0
0
CA
I wantto xcopy a file called "HPCK to HOME.COM" from Computer Pavilion dv7 with Vista on it to a nameless Desktop computer
with MS-OS XP on it and it doesnot work.
The batch file is labelled .COM as .BAT is reserved for XP;the file is in a attachment in this question.
Thank you very much for your help.





 
This is the batch file:
Cd\
C:
This will download the file "HPCK to HOME.com" to the computer HOME with the name "HPCK to HOME.COM"
xcopy:C\Charles\word-program\\batch\"HPCK to HOME.COM"
\\HOME\c:|Download\"HPCK to HOME.COM"

It doesnot work and I have save the file as a text file, not a word file.
 
Correction:
I Said that the file name is: HPCK to HOME.COM", but this is wrong, it should be "HPCK to HOME.CMD". I a using the extension .CMD, because the extension .BAT is reserved for XP
OS.

I am sorry for this mistake.

 
Where to start.

1. The "This will download the file..." line is of course n invalid command and will throw an error. Try using the echo statement to output text to screen if that's what you want.

Code:
echo "This text will be output to screen, and not interpreted as a command and tried to run"


2.This entire line:

Code:
 xcopy:C\Charles\word-program\\batch\"HPCK to HOME.COM"
      \\HOME\c:|Download\"HPCK to HOME.COM"

Is invalid.

A. You shouldn't be placing a colon ":" after the xcopy command.
B. You have two slashes in your path, which likely makes it invalid.
C. You can't have quotes in the middle of your file path, either the entire path is surrounded or nothing is.
D. You can't access the networked computer's C drive like that. That is again an invalid path.
Either you share C: drive correctly, or you can attempt to use the C$ administrative share to access it. However the admin share is only available if you are an administrator in both computers.

It should end up looking something like this:
Code:
@ECHO OFF
Cd\
C:
[red]echo[/red] [green]This will download the file "HPCK to HOME.com" to the computer HOME with the name "HPCK to HOME.COM"[/green]
xcopy [red]"[/red][green]C:\Charles\word-program\batch\HPCK to HOME.COM[/green][red]"[/red] [green]\\HOME\cdrivesharename\Download\[/green]

Also I'm pretty sure Windows Vista can run .BAT files just fine.


----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Behind the Web, Tips and Tricks for Web Development.
 
Vacunita, Thank you very much for your kind Help. I'm not clear as to what I should use instead of "cdrivesharename".
Can I use C:\Charles, shared by me" or what should the command
be.
By the way, I changed the file name to"C:\Charles\
HPCK to HOME.bat, Will this be acceptable?

What command shall I use to execute this file?

Charles Keller, Kelowna.
 
Thank you very much for your kind Help. I'm not clear as to what I should use instead of "cdrivesharename".
Can I use C:\Charles, shared by me" or what should the command

No, that's entire point. You need to have shared either the C: drive directly, or the folder you want to place this in, and use whatever name you gave it. Its not a direct system path such as C:\whatever\ but a relative shared resource name.
\\computername\sharename\

When You right clicked on the C: drive and click on Share you gave the shared resource a name, or it was given one automatically by windows. That's the name you use.

You can check what name it has by browsing to the computer and checking out the shares it has:


Vista_view_of_server_folders.png


\\computer\[red]backup[/red]

or

\\computer\[red]tech[/red]\

whatever you called C. as a guess it may be just C so

\\computer\[red]C[/red]\Charles\

Code:
xcopy "C:\Charles\HPCK to HOME.BAT" \\HOME\[red]C_Share_Name[/red]\Download\






----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Behind the Web, Tips and Tricks for Web Development.
 
Thank you Vacunita for your kind answer.Can I use the following line:
xcopy "C:\Charles\Batch\HPCK to HOME.bat"
\\HOME\C:\sharedDocs\Download

"sharedDocs" is the name I always use in the "HOME" computer.

What do I do to execute the file HPCK to HOME.BAT at the HPCK computer level?

Thank you kindly.

Charles Keller, Kelowna.
 
This might be a silly question (as Inspector Columbo on TV might say), but after reading this thread, if the two computers can 'see' each other on the home network, couldn't this work ? : On one PC, just map the drive on the other computer, and just copy and paste the file from one machine to the other, then rename it at the destination if necessary.

Fred Wagner

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top