AJWhite1970 Posted March 14, 2013 Posted March 14, 2013 Hi. Firstly, I'm not a vbs coder so if this is blindingly simple then I apologize in advance I'm looking to add to my students simple vbs login script so that I can run an .exe file but only if the time is between 08:00 and 15:40. So basically if time >= 08:00 or time <=15:40 then run myfile.exe else end Any help would be greatly appreciated. Regards Andrew
ricki Posted March 14, 2013 Posted March 14, 2013 HI Can you not used scheduled tasks. You can do this in gpo. Richard 1
AJWhite1970 Posted March 14, 2013 Author Posted March 14, 2013 I don't think so. When I looked I could either run a task on login or at a scheduled time but I couldn't see how to schedule it between two set times. Andrew
cromertech Posted March 14, 2013 Posted March 14, 2013 (edited) You can use a scheduled task for this if it is only for your students but it will probably need to be setup to run at log on and then repeated every hour until log off. If it's absolutely necessary to run it between those times you can create an item level target for a time frame. You can copy and paste the following into the Group Policy Preferences scheduled task dialog and edit as needed. Remember to edit the author section in red to your user before pasting. [color=#ff0000]{domain}\{user}[/color] Run a file at logon during a certain time of day %LogonDomain%\%LogonUser% InteractiveToken LeastPrivilege PT5M PT1H false false IgnoreNew false false false false true false PT0S 7 true %LogonDomain%\%LogonUser% PT1H P1D false myfile.exe Edited March 14, 2013 by cromertech reformat horrible XML 1
LosOjos Posted March 14, 2013 Posted March 14, 2013 (edited) Something like this as a logon script should do it: On Error Resume Next DIM objShell DIM startTime DIM endTime DIM curTime ' Set start time of the script. startTime=FormatDateTime("08:00", 4) ' Set end time of the script. endTime=FormatDateTime("15:40", 4) 'current time curTime=FormatDateTime(Time, 4) IF curTime>=startTime AND curTime<=endTime THEN SET objShell = CreateObject("WScript.Shell") ' Insert here your Application to run objShell.Run "%windir%\notepad.exe" SET objShell=Nothing END IF EDIT: changed the code to simplify and remove a glaring logic error! Edited March 14, 2013 by LosOjos 1
AJWhite1970 Posted March 14, 2013 Author Posted March 14, 2013 Thanks to everyone for their help, epically @LosOjos I now have this working exactly how I need it Andrew
LosOjos Posted March 14, 2013 Posted March 14, 2013 Thanks to everyone for their help, epically @LosOjos I now have this working exactly how I need it Andrew Happy to help
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now