?
Solved

Batch scripting - how to update text results file.

Posted on 2007-03-29
4
Medium Priority
?
266 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 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

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…
I've always wanted to allow a user to have a printer no matter where they login. The steps below will show you how to achieve just that. In this Article I'll show how to deploy printers automatically with group policy and then using security fil…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?

864 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