Getting bat file to work on other drives

Microsoft Windows 7 home premium upgrade...
December 8, 2009 at 13:38:36
Specs: Windows Vista
I'm a real rookie here.

I've been able to use BAT files no problem when executed and processing from C: drive but whenever I try to launch and process from network directory my BAT's do not work. Any ideas? I did try CD command but no luck.

I'm trying to run a batch that deletes blank rows...my example code I'm using is:
@Echo off
For /F "tokens=1 delims=" %%A in (\\server12\work\projects\orig.txt) Do Echo %%A >> \\server12\work\projects\new.txt


See More: Getting bat file to work on other drives

Report •


#1
December 8, 2009 at 18:30:11
also a rookie, so take under advisement. do you have all the permissions and authority to write to \\server. check disk and file sharing and firewall settings. see if echoing back to localdisk works:
For /F "tokens=1 delims=" %%A in (\\server12\work\projects\orig.txt) Do Echo %%A >> new.txt)
and see if new.txt (on local C: drive) gets result.


Report •

#2
December 9, 2009 at 03:17:21
I tested your code and it works fine here, using Vista. Try what nbrane suggests.

Report •

#3
December 9, 2009 at 03:22:58
"I did try CD command but no luck."

Doesn't say much.


=====================================
Helping others achieve escape felicity

M2


Report •

Related Solutions

#4
December 9, 2009 at 07:07:51
Thanks nbrane. However, still no luck. Permissions appear to be ok as I have other REN type batch files that work ok. I tried point back to C: as suggested and can't get it to copy back.

Report •

#5
December 9, 2009 at 09:16:28
What's the exact error message?

Report •

#6
December 9, 2009 at 13:08:56
yeah, i tried a duplicate scenario and it worked on my end. I do have my root share set up as C, so it looks like:
\\oldcomp\c\work\test.txt
but that's the only diff. so i guess i'm stymied since everything worked.
I would suggest always setting local even though your code doesn't use a "set", i've learned the hard way about external environment interference with variables.

Report •

#7
December 9, 2009 at 13:14:40
As yet, we don't know what the prob is.


=====================================
Helping others achieve escape felicity

M2


Report •

#8
December 11, 2009 at 11:55:08
My advice would be to get whatever network drive mapped, as quickly as possible, then use the driveletter for any further actions. The "cd" command wouldn't work with \\servername\blabla anyway

Report •

#9
December 11, 2009 at 12:32:46
Have you tried this yet?

type \\server12\work\projects\orig.txt >> \\server12\work\projects\new.txt

Much simpler than the code you where doing.

Oops never mind I see what you are doing.

So have you tried just copying the file to you C: drive working on it and sending it back like...

copy \\server12\work\projects\orig.txt c:
For /F "tokens=1 delims=" %%A in (c:\orig.txt) Do Echo %%A >> c:\new.txt)
copy c:\new.txt \\server12\work\projects\new.txt
del c:\new.txt
del c:\orig.txt

But like said above what is the error you are getting?


Report •

#10
December 11, 2009 at 14:21:53
No sure how to capture error message. Can you advise as the DOS window appears and disappears too quickly.

Report •

#11
December 11, 2009 at 15:39:08
Add the command PAUSE at the end of the batch file. Or, better
still, don't just run it by double-clicking it in Explorer. Start a
Command Prompt Window (Start -> All Programs ->
Accessories -> Command Prompt). CD to the directory where
the batch file is, then run it. When the script finishes it will leave
you in the same window where you can see the error
message(s) and then you can copy & paste them here.

Report •


Ask Question