Solved

Batch scripting - how to update text results file.

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

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Join & Write a Comment

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…
On July 14th 2015, Windows Server 2003 will become End of Support, leaving hundreds of thousands of servers around the world that still run this 12 year old operating system vulnerable and potentially out of compliance in many organisations around t…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

760 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

21 Experts available now in Live!

Get 1:1 Help Now