Discussion Locked

I need scripting help

0 helpful
7 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Hello all,
I am a recent graduate and I just landed my first Systems Administrator job. I have these computers that we use as data hosts for our raw data files. Needless to say that need to be defragged often so I wrote a batch file to do that, but I want to know when it runs without having to go to all of the machines to see the last time the task was run. I would like to put an operand at the end of the defrag script to write the machine name and the date and time the sript ran to a log file I created on my server. This seems possible, but I am not familiar with advanced scripting. Could someone please help me out. I have about 150 of these machines that I need to verify, I would really love to just add it to the end of the current script. Thanks for your assistance.

7 replies

by faradhi

then it should be as simple as adding

echo %date%,%time%,%computername% >> {filename}

to the end of your batch file.

by faradhi

I got slammed. Right now I am just in the eye of the storm. So I decided to poke in and see what is going on.

by kylegeldmaker

Thanks for your help, but I was unable to get the it to work, heres the batch file text.

CMD /c C:\dirms/dirms.exe c defrag
ECHO %date%,%time%,%computername% >> {c:\log.txt}
CMD /c shutdown -r -f -t 900

I am not sure where to go from here. I would like to get these on all of the existing machines, as well as all of the new ones. Once again, thanks for your help.

by faradhi

CMD /c C:\dirms/dirms.exe c defrag
ECHO %date%,%time%,%computername% >> c:\log.txt
CMD /c shutdown -r -f -t 900

Also, these types of questions would be a better fit in the Tech Q&A.

by kylegeldmaker

Ahhh, Brackets. Not it works.
I will post in the Q&A from now on. I have one more question though. Is there a website or a book that will give me a list of all the variables, like date, time, etc. that are possible to use in a script. I am pretty new to scripting. I would really appreciate it. Thanks again for your help.

This discussion is closed to new replies.