Hi my name is Nick and I'm trying to get a script or a batch file to work.
The script / batch must be some thing like to run a scpecific command only if today is the first of the monh. If not just go to end.
But I'm having hard time getting this to work. the problem is I can not define command which will check if current time is such and scuch and proceed to the C:\mybatch.bat
I'm just trying to have another batchfile to be ran only once a mnoth.

Can anyone please help me out there.
It would be greatly apprciated.

Sincerly,
Nick

[:o]
0 Comments   [ + ] Show Comments

Comments

Please log in to comment

Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.

Answers

0
I don't know if this helps in your situation, but you could use the Scheduled Tasks applet in Control Panel or the AT command from a command prompt to do this sort of thing.

Alternatively, if you don't mind using freeware executables, take a look at the ISDAY utility.

Regards,

Spartacus
Answered 12/15/2006 by: spartacus
Black Belt

Please log in to comment
0
Thanks Spartacus...

So far if I try to use a sceduled task and have a batch file to copy scheduled task to other machines I will loose the LOg On As credentials after the task has beeen copied over.
The othe roption using the AT command requires another service to be installed and runn all the time for AT commeand to be able to operate.
I think my only solution would be a VBS script, but I'm not sure how excatly to script it.

Any help would be greatfull.
Nick
Answered 12/18/2006 by: nbasic26
Senior Yellow Belt

Please log in to comment
0
Ok, how about this

Set WshShell = WScript.CreateObject("WScript.Shell")
strrun = "cmd.exe /c ""C:\MYBATCH.BAT"""
datetime = formatdatetime(now(),1)
dateinmonth = split(datetime)
if cint(dateinmonth(0)) = 1 then
msgbox "It is the first day of the month, running batch file ..."
WshShell.Run strrun
end if


Note, this works for UK locale date and time, so you may need to alter to your own local
requirements.

Regards,

Spartacus
Answered 12/18/2006 by: spartacus
Black Belt

Please log in to comment
0
Thanks again Spartacus.

The only problem I have right now is with the line 5 "if cint" command line. When I attemp to run the script it pops the following error message box.
Error: Type mismatch 'cint'
Code: 800A000D

I'm not a script pro so I hope you will excuse my questions regrding those VBS comands.

Sincerly,
Nick
Answered 12/21/2006 by: nbasic26
Senior Yellow Belt

Please log in to comment
0
Try this;

Set WshShell = WScript.CreateObject("WScript.Shell")
strrun = "cmd.exe /c ""C:\MYBATCH.BAT"""
datetime = FormatDateTime(now(),2)
dateinmonth = Split(datetime, "/")
If dateinmonth(1) = 1 Then
MsgBox "It is the first day of the month, running batch file ..."
WshShell.Run strrun
Else
msgbox "It is the "& dateinmonth(1) & " day of the month, No batch file today ..."
end If
Answered 12/21/2006 by: Robo Scripter
Orange Senior Belt

Please log in to comment
Answer this question or Comment on this question for clarity