PC Review


Reply
Thread Tools Rate Thread

Create output file named using date and time???

 
 
numismatic
Guest
Posts: n/a
 
      6th May 2008
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?
 
Reply With Quote
 
 
 
 
numismatic
Guest
Posts: n/a
 
      6th May 2008
On May 6, 3:18 pm, numismatic <MarkEllisAl...@gmail.com> wrote:
> 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?


or:

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

returns a file named "msservices - Tue"...no .txt or the full date.
 
Reply With Quote
 
Pegasus \(MVP\)
Guest
Posts: n/a
 
      6th May 2008

"numismatic" <(E-Mail Removed)> wrote in message
news:34428012-70c5-49dd-ba2f-(E-Mail Removed)...
> 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?


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.


 
Reply With Quote
 
Timo Salmi
Guest
Posts: n/a
 
      7th May 2008
numismatic <(E-Mail Removed)> 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
private.php?do=newpm&u= <http://www.uwasa.fi/~ts/> ; FI-65101, Finland
Useful script files and tricks ftp://garbo.uwasa.fi/pc/link/tscmd.zip
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Output the "Created Time/Date" to an Excel file bdmsfan Microsoft Access Macros 2 19th Dec 2007 07:52 PM
Can output file name from access query-create table include date . =?Utf-8?B?SkNvZmY=?= Microsoft Access Macros 1 20th Mar 2006 11:42 PM
Using The System Date and Time to Create Unique File Extensions. srulison@mail.state.il.us Windows XP General 0 11th Oct 2005 08:33 PM
Using The System Date and Time to Create Unique File Extensions. srulison@mail.state.il.us Windows XP General 0 11th Oct 2005 08:07 PM
Output to - Adding a date to the Output File Argument =?Utf-8?B?VGltYm9i?= Microsoft Access Macros 2 22nd Oct 2004 04:36 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:15 AM.