Batch file incorrect writing to txt file

Solved/Closed
System-One - Nov 13, 2008 at 10:47 AM
Coco_B Posts 1 Registration date Thursday November 13, 2008 Status Member Last seen November 14, 2008 - Nov 14, 2008 at 11:38 AM
Hello dear friends,

I have some trouble writing some application data from windows to a .txt file located on a usb stick (E:/ cant even CD it), however when i relocate the log.bat on the C drive it works fine!

Can anyone spot my error i cant find out what im doing wrong.... here goes the code:

[code log.bat]

CD C:\Users\system-one\AppData\Roaming\Microsoft\Windows\Start Menu\Programs
echo Computernaam: %COMPUTERNAME% >> %~d0\fi-pc.txt
echo Gebruikt door: %USERNAME% >> %~d0\fi-pc.txt
echo Datum: %date% >> %~d0\fi-pc.txt
echo. >> %~d0\fi-pc.txt
echo Programma's menu start: >> %~d0\fi-pc.txt
echo ----- >> %~d0\fi-pc.txt
DIR /b >> %~d0\fi-pc.txt
echo ----- >> %~d0\fi-pc.txt
echo. >> %~d0\fi-pc.txt
echo Program Files: >> %~d0\fi-pc.txt
echo ----- >> %~d0\fi-pc.txt
CD %programfiles%
Dir /b >> %~d0\fi-pc.txt
echo ----- >> %~d0\fi-pc.txt
echo -END- >> %~d0\fi-pc.txt
echo. >> %~d0\fi-pc.txt
echo. >> %~d0\fi-pc.txt
echo -NEW- >> %~d0\fi-pc.txt
echo. >> %~d0\fi-pc.txt
CD %~d0\

[/code]

It writes a text file with the dir data of the usb stick when launched from usb stick!?

Best Regards,

Noob
Related:

2 responses

Try with CHDIR /D
2
Thanks COCO that does the trick!
0
Coco_B Posts 1 Registration date Thursday November 13, 2008 Status Member Last seen November 14, 2008 1
Nov 14, 2008 at 11:38 AM
No problem, happy to help!
1