General discussion

Locked

I need scripting help

By kylegeldmaker ·
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.

This conversation is currently closed to new comments.

7 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

If using XP, 2k3, or 2k

by faradhi In reply to I need scripting help

then it should be as simple as adding

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

to the end of your batch file.

Collapse -

faradhi, I know this is off topic but

by Old Guy In reply to If using XP, 2k3, or 2k

welcome back. I haven't seen you posting in awhile.

Collapse -

thanks,

by faradhi In reply to faradhi, I know this is o ...

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.

Collapse -

Faradhi, it didn't work.

by kylegeldmaker In reply to thanks,

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.

Collapse -

leave the brackets out

by faradhi In reply to Faradhi, it didn't work.

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.

Collapse -

sweet.

by kylegeldmaker In reply to leave the brackets out

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.

Collapse -

Here are two to get you started

by faradhi In reply to sweet.

http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/ntcmds.mspx?mfr=true
http://www.computerhope.com/batch.htm

You should also look at some other scripting languages like VB, Jscript or Perl.

Remember with scripting there are two facts to remember.

1) If you need a script, chances are someone else has needed it and posted it somewhere on the internet.
2) Google is your friend.

Good luck!

Bryan

Back to IT Employment Forum
7 total posts (Page 1 of 1)  

Related Discussions

Related Forums