Solved

Batch scripting - how to update text results file.

Posted on 2007-03-29
4
253 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
  • 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 500 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Learn about cloud computing and its benefits for small business owners.
ADCs have gained traction within the last decade, largely due to increased demand for legacy load balancing appliances to handle more advanced application delivery requirements and improve application performance.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

863 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

Need Help in Real-Time?

Connect with top rated Experts

28 Experts available now in Live!

Get 1:1 Help Now