?
Solved

Batch scripting - how to update text results file.

Posted on 2007-03-29
4
Medium Priority
?
264 Views
Last Modified: 2010-04-18
I wrote  batch script that will write some variables to the text file located on netshare and create batch file based on some variables that will be created on workstation and run later.
How do I write to a text file on netshare so I have one file with entries from all of the machines instead of many separate files - one for each machine. Another words -  when I run the script now -  I get the the separate results file for each workstation or if I do not customize file name -  I get the previous entries over written in that file -  I would like to have all data in one file so I can easily import it into database.
The script I have so far is as follows:
@echo off
cd \documents and settings\les
for /f "tokens=3" %%a in ('dir /-c/s ^| find "File(s)"') do set sizeofdir=%%a

rem Writing all info I need for this machine to results.txt located on netshare
echo Directory Size: %sizeofdir% Logon Server: %LOGONSERVER%  Computer Name: %COMPUTERNAME% ^
User Name: %USERNAME%  User Domain: %USERDOMAIN%  User Profile: %USERPROFILE% > path to netshare\results.txt

rem Creating batch file on workstation that will run the copy
echo xcopy "C:\documents and settings\%USERNAME%" "C:\documents and settings\%USERNAME%.%COMPUTERNAME%" /s /e /h > c:\runcopy.bat

Thanks,

Les
0
Comment
Question by:lescluster
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 67

Expert Comment

by:sirbounty
ID: 18821291
Use >> to append text...

echo Directory Size: %sizeofdir% Logon Server: %LOGONSERVER%  Computer Name: %COMPUTERNAME% ^
User Name: %USERNAME%  User Domain: %USERDOMAIN%  User Profile: %USERPROFILE% >> path to netshare\results.txt

rem Creating batch file on workstation that will run the copy
echo xcopy "C:\documents and settings\%USERNAME%" "C:\documents and settings\%USERNAME%.%COMPUTERNAME%" /s /e /h >> c:\runcopy.bat
0
 
LVL 67

Accepted Solution

by:
sirbounty earned 2000 total points
ID: 18821294
Actually, I don't guess you'd need to append to the second one.. : )
0
 

Author Comment

by:lescluster
ID: 18821321
That easy - Thanks - making me feel really stupid :)
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 18821339
Sorry about that. :^)
Happy to help.
Thanx for the grade!
0

Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This may not be a text book method to resolve VSS backup issues but it seemed to have worked on few of the Windows 2003 servers we had issues while performing a Volume Shadow Copy backup. If you have issues while performing a shadow copy backup usin…
Scenerio: You have a server running Server 2003 and have applied a retail pack of Terminal Server Licenses.  You want to change servers or your server has crashed and you need to reapply the Terminal Server Licenses. When you enter the 16-digit lic…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question