Using DOS commands to set sysdate and systime 
Author Message
 Using DOS commands to set sysdate and systime

Hello all,

I want to use the DOS date command to set the system date from a script
(unless there is a native WSH, VBScript or ActivePerl  way, which I
couldn't find). How do I do that? I tried:

sh.Run "command.com date" & chr(34) & date & chr(34)

which doesn't work. I am not sure you can actually pass parameters to
command.com.

Does anybody have an idea?

Thanks for any help.

Regards,

Jan van Mansum.



Sun, 08 Dec 2002 03:00:00 GMT  
 Using DOS commands to set sysdate and systime

Quote:

> Hello all,

> I want to use the DOS date command to set the system date from a script
> (unless there is a native WSH, VBScript or ActivePerl  way, which I
> couldn't find). How do I do that? I tried:

> sh.Run "command.com date" & chr(34) & date & chr(34)

> which doesn't work. I am not sure you can actually pass parameters to
> command.com.

> Does anybody have an idea?

> Thanks for any help.

> Regards,

> Jan van Mansum.

Why are you enclosing the date in double quotes?  Do you do it that way
from the command prompt?  (I don't ;-)

Your statement should read ...

sh.Run "%comspec% date " & date, 0, True

Using the Comspec variable to reference the command processor is
generally better than trying to directly call it. A space is also needed
between the DATE command and the literal date.  Of course, I am assuming
'date' names a variable that contains a valid string designation of the
desired date.  For example, 1/1/2000 or 2-2-2000 or even 3.3.2000.

I took the liberty of adding a zero intWindowStyle value to hide the DOS
window and the True bWaitOnReturn parameter to be certain the correct
date is set before the next script statement is executed.

Tom Lavedas
-----------
http://www.pressroom.com/~tglbatch/



Sun, 08 Dec 2002 03:00:00 GMT  
 Using DOS commands to set sysdate and systime
Have you tried:

->
Shell.Run "%comspec% date 21/6/2000"
<-
or:
->
Shell.Run "%comspec% date " &FormatDateTime(Date, 2)
<-
--
Dominic



Sun, 08 Dec 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Using DOS commands to set sysdate and systime

2. Using Dos commands without dos window

3. Run a DOS command and Get output of a DOS command in VB5

4. Print tiff image to printer using DOS command or ghostscript

5. Running DOS Shell in hidden window, or using vb command instead

6. running DOS commands on NT using WSH

7. using internal dos commands with shell.run ?

8. Using MS-DOS command in JScript

9. vb and dos set command

10. DOS Commands Using VBA

11. Problem executing DOS command using Shell function

12. Using DOS commands in VB code?

 

 
Powered by phpBB® Forum Software