Date Reset & Launch App

Hello,

I’m in need of a script that would help do the following:

  1. open sys prefs, set back my date 2-3years and save
  2. launch an app
  3. reset the time & date to serve & quite sys prefs

:lol:

Thanks

I have to ask, why in the the heck you would want to do this?

I smell a way to beat an evaluation registration timeout…

Jon

I’m sure the poster has a ligitimate reason for wanting to do this, which presently escapes me. I just want to know why. And I have to admit, that I’m really curious about the 3 or 2 years thingy tho – (that’s cajun for 2 or 3 years) – I’m totally lost on the “serve & quite sys prefs” request tho!

Hi All,

Sorry, that’s deep south for “set Time & Date to Network Time Server and then quite System Preferences.”

Jon is part right, I don’t know the cause, but it’s a program that runs an older ARRI film camera. I contacted the company and the tech support guy told me that they are no longer supporting or updating MY program version to OS X.

I actually have to launch a classic program in classic mode.

Now, the part that gets me is that the classic program does not like Y2K dates and will lock up. The tech guy at least told me, to back the date up into 1999 (i guess i should have mentioned this) and then launch.

My other options are to buy the NEW $1500 version or is to run purely in OS 9 :x I’m an OS X person and hate going into 9. I don’t even like the fact that I have to use classic. If I needed the new version, i would get it. I just hate the fact of rebooting into 9, which by the way gives me no access to the other OS X programs i need on set.

Thanks for the inquiries.

-Alfeo

The short answer is you’re making the classic mistake of trying to get AppleScript to do something that way you’d do it, rather than just telling it to do what you want.

The manual way of doing this it to open system preferences, poke around a bit, clicking, typing, etc., etc. Bleugh!

The direct way of doing it is to just tell the system to set the date to the required value. While there are a number of osaxen that will do this for you, you can also do this via shell scripts (untested):

set cur_date to do shell script "date +%G%m%d%H%M.%S" -- record the current date so we can reset it
do shell script "date 199901010101" with administrator privileges -- set the date to Jan 1, 1999 
open "path:to:your.app" -- launch the app
set cur_date to cur_date + 0.10 -- add 10 seconds to the previously-recorded date, adjust as necessary to allow for app launch time
do shell script "date " & cur_date with administrator privileges -- and reset the date

Ran the script from Script Editor and I get:

AppleScript Error
Mon Mar 1 00:00 EST 2027

Which sets the date to the above.

It also highlighted this text in the script:
do shell script “date 1999010101” with administrator privileges

Is this correct for the application path?
“path:to:Arricam 2.app.”

-Alfeo

According to the manual page for “date” …

     The command:

           date 8506131627

     sets the date to ``June 13, 1985, 4:27 PM''

1999010101might be throwing the script off, I am not sure.

So you may not need to use the full year as in 1999010101-- try 9901010101, which translates to “1999, Jan 01, 01:01am”
I’m not willing to test this because I don’t want to mess with my system clock. In the terminal.app type ‘man date’ for more info. Good luck!

PS: I am totally unsure about this…

No, it’s probably something like:

“Macintosh HD:Applications:Arricam 2.app”

depending on your startup drive’s name and the name(s) of the enclosing folder(s).

Jon

Still getting the same error

The date & time does change to this date I set

"date 99012500803"

I also switched:

open "Powerbook G4 HD:Applications:ARRI:ARRI 2.app" -- launch the app

For:

tell application "ARRI 2" to activate

Anymore suggestions?

-Alfeo

The problem may be that “date 99012500803” has one too many numbers in it. It should be formatted like this “yymmddhhmm” ex. → 99 01 25 08 03 (with no spaces. ) It might be a just typo in your message though.

Type “date +%y%m%d%k%M” in the terminal app to get the current date, then try to change it in the terminal app to

date 9901250803

Again, untested and unsure – be careless :slight_smile:

Also, which are you getting? – just to be sure.

Yes, that was a typo.

date 9901250803

is what I have.
Tried in terminal to change and this resulted

Still getting same AppleScript Error, but it does set the time back

-Alfeo

You might need to use sudo …

sudo date 9901250803
password: enter your admin password

Again, I’m still unsure! Aslo note that any other files you open, while you are in the predated System, will probably get a modification and access date of whatever date the System is set to. I’m not sure if that will cause any problems or not, most likely not.

If the above “sudo command” works and this is something you need to do on a regular basis, you could make an alias of the command and keep it in a ~/.tcshrc file. (assuming you are using tcsh as your shell). If that’s something you are not familiar with, email me and I’ll be glad to help you with that.

greg at macscripter.net

Slowly, but surely!

sudo date 9901250803

worked in terminal fine.
Now I have a different AppleScript Error:

or using “date +%y%m%d%k%M” in place of “date +%G%m%d%H%M.%S”

No, I am not familiar at-all with tcsh and shell.

-Alfeo

Whoops, that first date thing should be

do shell script "date +%y%m%d%H%M"

Sorry 'bout that. But that is not that important as it doesn’t affect the outcome, it’s just there to give you the current date so that you can use it to set it back to today.

I see that the script result has that bad number in it again (990125803), it should be (9901250803) 10 dgits. That could be giving you the date format error.

Back to first AppleScript Error:

does, change date & time. Same result with or w/out “sudo” in line 2

This thread is getting to long to remember what the first AppleScript Error was, or I’m getting to sleepy :shock:

The only other thing I can suggest is to try it without the admin priv’s in the script

do shell script "date 9901250803"

If that still errors then try it with the seconds added as Camelot suggested

do shell script "date +%y%m%d%H%M.%S

This works for me:

Of course, if you were on a secure machine, you could hardcode your password like so:

Jon

OH, MY, GOD!

All of you guys ROCK!

Thank you so much for the help.

Thank you all.

-Alfeo

I forgot. If I’m not connected to the internet…
the app doesn’t complete its work to reset the date & time to back to the current time & date.

:shock:

-Alfeo