Quser using .bat

Hewlett-packard / DX2300
January 13, 2009 at 08:40:49
Specs: Windows XP, pentium 4 2gb ram

I have written a .bat file that parses data to a text file, which is then displayed in an html page. Basically the .bat file uses the quser command to query logged on users of servers. Here's an example of the .bat:

cd C:\Windows\System32
Echo MODWK136 >> S:\Query_RDP_MODWK\Result_Quser.txt
quser.exe /Server:MODWK136 >> S:\Query_RDP_MODWK\Result_Quser.txt
cd C:\Windows\System32
Echo MODWK137 >> S:\Query_RDP_MODWK\Result_Quser.txt
quser.exe /Server:MODWK137 >> S:\Query_RDP_MODWK\Result_Quser.txt

If I manually run the .bat it works and the correct info in displayed in the html page. However what I want it to do is to refresh every 30 mins so that the info in the Result_Quser.txt file is updated, hence showing the updated info in the html page.

However if I then run the .bat a second time it doesn't work because it only amends the Result_Quser.txt file rather than overwriting it, hence the html page shows the original data not the new. I have tried using > instead of >> but to no avail.

So my question is how to I overwrite the Result_Quser.txt file rather than amending it. I also want the .bat to run automatically every 30mins - what's the best way to do this - via the .bat?

Thanks for any help!


See More: Quser using .bat

Report •

January 13, 2009 at 10:09:26
to create new file:
echo off>test.txt
if exist test.txt del test.txt

to run automatically 30min, i can think of couple solutions:
1. use task scheduler
2. use sleep function

Report •
Related Solutions

Ask Question