Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Create output file named using date and time???

16 views
Skip to first unread message

numismatic

unread,
May 6, 2008, 4:18:40 PM5/6/08
to
I've done this before, but can't recall or find how it's done (it's
been a few years).

I want to run a command (psservice) and redirect output to a file
using the current date and time.

for example:

psservice query ms >> "%UserProfile%\Desktop\msservices - %date%.txt"

I know I've done this before fairly simply. Any ideas?

numismatic

unread,
May 6, 2008, 4:21:26 PM5/6/08
to

or:

psservice query ms >> "%UserProfile%\Desktop\msservices - "%date
%".txt"

returns a file named "msservices - Tue"...no .txt or the full date.

Pegasus (MVP)

unread,
May 6, 2008, 4:43:56 PM5/6/08
to

"numismatic" <MarkEll...@gmail.com> wrote in message
news:34428012-70c5-49dd...@k37g2000hsf.googlegroups.com...

The variable %date% resolves to something like
Tue 05/06/2008
which contains forward slashes. None of the MS operating
systems ever released allowed any kind of slash in its file names.
You must get rid of them, eg. like so:
@echo off
set MyDate=%date:/=-%
psservice query ms >> "%UserProfile%\Desktop\msservices - %MyDate%.txt"

I don't run psservice.exe on my machine, hence I cannot tell if
the syntax for this command is correct.


Timo Salmi

unread,
May 7, 2008, 9:29:19 AM5/7/08
to
numismatic <MarkEll...@gmail.com> wrote:
> I want to run a command (psservice) and redirect output to a file
> using the current date and time.

1) How to get today's date elements into environment variables?
http://www.netikka.net/tsneti/info/tscmd001.htm

All the best, Timo

--
Prof. Timo Salmi ftp & http://garbo.uwasa.fi/ archives 193.166.120.5
Department of Accounting and Business Finance ; University of Vaasa
mailto:t...@uwasa.fi <http://www.uwasa.fi/~ts/> ; FI-65101, Finland
Useful script files and tricks ftp://garbo.uwasa.fi/pc/link/tscmd.zip

0 new messages