date and time preferences

Is it possible to change the date and time preferences through applescript? I have tried various methods and none seem to work.
(If this is not possible could anyone direct me to any other way to do this automatically?)

Thanks in advance,

bob

AppleScript: 1.10.7
Operating System: Mac OS X (10.5)

Hi,

you can set date and time in Leopard with


do shell script "/usr/sbin/systemsetup -setdate 'mm:dd:yy' -settime 'hh:mm:ss'"

Worthwhile looking at the man page for systemsetup – there are a lot of things you can get or set there.

−getdate
Displays the current date.
−setdate mm:dd:yy
Use this command to set the current month, day,and year.
−gettime
Displays the current time in 24-hour format.
−settime hh:mm:ss
Sets the current time. The provided time argument should be in 24-hour format.
−gettimezone
Displays current time zone.
−listtimezones
Lists all time zones supported by this machine.
−settimezone timezone
Use this command to set the local time zone. Use “-listtimezones” to list valid timezone arguments.
−getusingnetworktime
Displays whether network time is on or off.
−setusingnetworktime on | off
Sets whether using network time is on or off.
−getnetworktimeserver
Displays the currently set network time server.
−setnetworktimeserver timeserver
Use this command to designate a network time server. Enter the IP address or DNS name for the
network time server.
−getsleep
Displays amount of idle time until machine sleeps.
−setsleep minutes
Sets amount of idle time until computer sleeps. Specify “Never” or “Off” for computers that should
neversleep. Important: if you set the system to sleep, you will not be able to administer the server
remotely while it is sleeping.
−getcomputersleep
Display amount of idle time until computer sleeps.
−setcomputersleep minutes
Set amount of idle time until computer sleeps. Specify “Never” or “Off” for never.
−getdisplaysleep
Display amount of idle time until display sleeps.
−setdisplaysleep minutes
Set amount of idle time until display sleeps. Specify “Never” or “Off” for never.
−getharddisksleep
Display amount of idle time until hard disk sleeps. Specify “Never” or “Off” for never.
−setharddisksleep
Set amount of idle time until hard disk sleeps. Specify “Never” or “Off” for never.
−getwakeonmodem
Displays whether wakeonmodem is on or off.
−setwakeonmodem on | off
Use this command to specify whether or not the server will wakefrom sleep when modem activity
is detected.
−getwakeonnetworkaccess
Displays whether wakeonnetwork access is on or off.
−setwakeonnetworkaccess on | off
Use this command to specify whether the server wakes from sleep when a network admin packet is
sent to it.
−getrestartpowerfailure
Displays whether restart on power failure is on or off.
−setrestartpowerfailure on | off
Use this command to specify whether the server automatically restarts after a power failure.
−getrestartfreeze
Displays whether restart on freeze is on or off.
−setrestartfreeze on | off
Use this command to specify whether the server restarts automatically after the system freezes.
−getallowpowerbuttontosleepcomputer
Enable or disable whether the power button can sleep the computer.
−setallowpowerbuttontosleepcomputer on | off
Enable or disable whether the power button can sleep the computer.
−getremotelogin
Displays whether remote login (SSH) is on or off.
−setremotelogin [-f] on | off
Sets remote login (SSH) to either on or off. Important If you turn offremote login, you won’t be
able to administer the server using remote command line tools and SSH. Toturn remote login back
on, you’ll need to connect a monitor and keyboard to the server to administer it locally. Use
“setremotelogin -f off” to suppress prompting when turning remote login off.
−getremoteappleevents
Displays whether remote apple events are on or off.
−setremoteappleevents on | off
Use this command to set whether the server responds to events sent by other computers (such as
AppleScripts).
−getcomputername
Displays computer name.
−setcomputername computername
Sets computer name to . This name is used by AFP and AppleTalk.
−getlocalsubnetname
Display local subnet name.
−setlocalsubnetname name
Set local subnet name to .
−getstartupdisk
Displays current startup disk.
−liststartupdisks
Lists all valid startup disks on this computer.
−setstartupdisk path
Sets current startup disk to the indicated path. Valid arguments can be listed using “-liststar-
tupdisks.”
−getwaitforstartupafterpowerfailure
Get the number of seconds after which the computer will start up after a power failure.
−setwaitforstartupafterpowerfailure seconds
Set the number of seconds after which the computer will start up after a power failure. The value must be a multiple of 30 seconds.
−getdisablekeyboardwhenenclosurelockisengaged
Get whether or not the keyboard should be disabled when the X Serveenclosure lock is engaged.
−setdisablekeyboardwhenenclosurelockisengaged yes | no
Set whether or not the keyboard should be disabled when the X Serveenclosure lock is engaged.

Thanks Adam, got it working. :slight_smile:

[EDIT]do shell script "/System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Support/systemsetup -setusingnetworktime off"
Is there a better way to do that?

bump
Sorry, I edited my previous message but the thread is already buried.