Batch file incorrect writing to txt file [Solved/Closed]

Report
-
Posts
1
Registration date
Thursday November 13, 2008
Status
Member
Last seen
November 14, 2008
-
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

2 replies

Try with CHDIR /D
2
Thank you

A few words of thanks would be greatly appreciated. Add comment

CCM 2942 users have said thank you to us this month

Thanks COCO that does the trick!
Posts
1
Registration date
Thursday November 13, 2008
Status
Member
Last seen
November 14, 2008
1
No problem, happy to help!