Solved

Batch scripting - how to update text results file.

Posted on 2007-03-29
4
256 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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Suggested Solutions

Recently, I had the need to build a standalone system to run a point-of-sale system. I’m running this on a low-voltage Atom processor, so I wanted a light-weight operating system, but still needed Windows. I chose to use Microsoft Windows Server 200…
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…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

830 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