Search : in
By :

Batch file incorrect writing to txt file

Last answer on Nov 14, 2008 4:38:16 pm GMT System-One, on Nov 13, 2008 3:47:36 pm GMT 
 Report this message to moderators

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

Configuration: Windows Vista
Firefox 3.0.3

Best answers for « Batch file incorrect writing to txt file » in :
Writing in batch in text file Show Writing in batch in text file To write in a file text, you just have to use a redirect: echo text > output_file.txt To write in an existing file: echo " Write at the end of the file ">> output_file.txt
Batch file ShowBatch file Settings File Creation DOS is integrated in windows which allow to exploit functionality and command sequence in a script. A batch file is a text file which contains command to be read by DOS. This file can be launched...
What is a batch file? ShowWhat is a batch file? Creating a batch file Prerequisites Create file Windows comes with a version of DOS, which allows you,exploiting the features and the sequence of commands in a script. Batch file, is a simple text file (ascii)...
Renaming multiple files in batch ShowRenaming multiple files in batch Native features Using a third-party program Renaming a large number of files can quickly become tedious. Fortunately, there are tools to automate this task in many cases: Native features On Windows...
File sharing in Windows XP ShowAdvantages File sharing involves making the content of one or more directories available through the network. All Windows systems have standard devices making it easy to share the content of a directory. However, file sharing may lead to security...

1

Coco, on Nov 14, 2008 9:27:19 am GMT
  • +2

Try with CHDIR /D

Reply to Coco

2

System-One, on Nov 14, 2008 1:44:46 pm GMT

Thanks COCO that does the trick!

Reply to System-One

3

 Coco_B, on Nov 14, 2008 4:38:16 pm GMT
  • +1

No problem, happy to help!

Reply to Coco_B