Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Synchronize the computer's time
Message
De
05/02/2023 04:51:55
 
 
À
05/02/2023 03:35:50
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01686121
Message ID:
01686122
Vues:
48
>Good Morning,
>I would like to synchronize the computer's time with the time of a server on the net that is pointed to the following time: '0.europe.pool.ntp.org'
>I'm using the following command, but it doesn't work, any help is welcome:
>
>DECLARE INTEGER ShellExecute IN shell32.DLL ;
>INTEGER hndWin, ;
>STRING cAction, ;
>STRING cFileName, ;
>STRING cParams, ;
>STRING cDir, ;
>INTEGER nShowWin
>
>ShellExecute(0,"runas","cmd.exe","net stop w32time","",0) && sometimes Admin rights are needed!
>ShellExecute(0,"runas","cmd.exe","w32tm/config/manualpeerlist:0.europe.pool.ntp.org, 0X8, sincfromflags:manual","",0) && sometimes Admin rights are needed!
>ShellExecute(0,"runas","cmd.exe","net start w32time","",0) && sometimes Admin rights are needed!

The first hurdle is privileges - yes, you do need admin rights, and maybe an elevated CMD shell even if you're an admin. This is for a reason, system time is an admin function and should not be changed by regular user accounts.

Why do you need to change the system time configuration?

https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2012-r2-and-2012/ff799054(v=ws.11)
https://superuser.com/questions/1366277/windows-time-service-configuration-update-by-non-admin-user
https://superuser.com/questions/1160654/allow-non-administrator-users-to-synchronise-time-w32tm-resync

If you get past the privileges issue:
- you should not need to stop or start the service, just /configure, then /update, then /resync
- make sure your syntax is correct, there seem to be some errors in your sample code above
Regards. Al

"Violence is the last refuge of the incompetent." -- Isaac Asimov
"Never let your sense of morals prevent you from doing what is right." -- Isaac Asimov

Neither a despot, nor a doormat, be

Every app wants to be a database app when it grows up
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform