Hi,
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!
Steve
Quser using .bat
Started by mojo1979, Jan 13 2009 07:44 AM
4 replies to this topic
#1
Posted 13 January 2009 - 07:44 AM
|
|
|
#2
Posted 13 January 2009 - 09:12 AM
Why not delete the file before redirecting the results into it?
#3
Posted 13 January 2009 - 09:49 AM
Can I write this delete into the .bat?
#4
Posted 13 January 2009 - 11:56 AM
You should be able to, yes.
del S:\Query_RDP_MODWK\Result_Quser.txt 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
#5
Posted 13 January 2009 - 11:59 AM
Thanks this worked...
I guess I should just use tash scheduler to automate the running of the .bat...
I guess I should just use tash scheduler to automate the running of the .bat...


Sign In
Create Account

Back to top









