Posts: 369
Threads: 71
Joined: Jul 2022
Reputation:
14
Huh. As usual Steve, you have solved the problem for another DUH of mine.
Yes, running as admin makes it work!?
Erik.
Posts: 369
Threads: 71
Joined: Jul 2022
Reputation:
14
10-05-2023, 01:49 AM
(This post was last modified: 10-05-2023, 02:14 AM by eoredson.)
There may be a difference between SetLocalTime and SetSystemTime where the latter is UTC.
In control panel the date/time setting for internet clock will autoset the realtime anyway independent of what you set it for.
Erik.
Posts: 734
Threads: 30
Joined: Apr 2022
Reputation:
43
10-05-2023, 11:11 AM
(This post was last modified: 10-05-2023, 11:16 AM by SpriggsySpriggs.)
I've got code somewhere to make a program launch itself as admin. If I find it, I'll send it your way, eoredson.
EDIT: Looks like I found it
Of course, you'll have to accept the UAC prompt.
Code: (Select All)
Declare Dynamic Library "Shell32"
Function IsUserAnAdmin& ()
Sub ShellExecute Alias "ShellExecuteA" (ByVal hwnd As _Offset, lpOperation As String, lpFile As String, lpParameters As String, Byval lpDirectory As _Offset, Byval nShowCmd As Long)
End Declare
Sub SelfElevate
If IsUserAnAdmin = 0 Then
ShellExecute 0, "runas" + Chr$(0), Command$(0) + Chr$(0), Command$ + Chr$(0), 0, 5
System
End If
End Sub
Tread on those who tread on you
Posts: 734
Threads: 30
Joined: Apr 2022
Reputation:
43
Yeah. You have to leave the code as is. The `System` call is important. As is the `IsUserAnAdmin` check.
Tread on those who tread on you
Posts: 369
Threads: 71
Joined: Jul 2022
Reputation:
14
I removed the comment from 'System and it went into an endless loop anyway.
If IsUserAnAdmin check when 0 going to do the same thing?
Erik.
Posts: 734
Threads: 30
Joined: Apr 2022
Reputation:
43
10-06-2023, 02:58 AM
(This post was last modified: 10-06-2023, 03:00 AM by SpriggsySpriggs.)
It shouldn't do that. I've never seen it constantly loop on just that alone because it should report zero for normal user and nonzero for admin. If you cancel the UAC prompt, it is just going to close out anyways because the next statement is `System`. I've never had any issues using it, though. It (`SelfElevate`) is a big part of my registry library. But for future reference, leave the function as I provided. It was written this way for a reason.
Tread on those who tread on you