/build/static/layout/Breadcrumb_cap_w.png

I need help with "IF time is" script or batch

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

Answers (5)

Posted by: spartacus 17 years ago
Black Belt
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
Posted by: nbasic26 17 years ago
Senior Yellow Belt
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
Posted by: spartacus 17 years ago
Black Belt
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
Posted by: nbasic26 17 years ago
Senior Yellow Belt
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
Posted by: Robo Scripter 17 years ago
Orange Senior Belt
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
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ