-
"This computer's going to sleep after 3 minutes"
I want to make a small utility app that after a certain time of the day (night, actually) prompts the current user to log off. If after a few minutes he/she hasn't, then the program takes over automatically and logs off (or shuts down, or goes to sleep mode, or deactivates the hard disk...) It should run at Windows (XP) start. The idea is to prevent my daughter from sticking around the computer until very late.
I just don't know where to start, maybe some API function should help, but I need some guidance.
Or perhaps there's some freeware out there that deals with this?
-
Re: "This computer's going to sleep after 3 minutes"
You can subclass your form and listen for WM_TIMECHANGE. I'm not sure if this happens every second or every minute.. I can't test it now as I'm at work.
Then its just as simple as checking the time after this event, prompting, waiting a minute, then logging the PC off (or shutting it down).
chem
-
Re: "This computer's going to sleep after 3 minutes"
Subclassing is one way to go, but unless you are subclassing for other reasons, I'd recommend using a timer (vb timer limited to max of 1 min intervals), one created by SetTimer (all O/S) or possibly the CreateTimerQueueTimer API (Win2K & higher only), which both can be set at a much higher interval. Before determining the timer interval, do some simple math -- calculate how many seconds*1000 you want the timer to fire and when it fires, then prompt for shutdown.
To get your app to run at startup, it can be added to the AutoExec.Bat file, window scheduler, added to the Run registry hive, and other options.
To shut down the pc, look at the InitiateSystemShutdown API (not avail on Win9x).
-
Re: "This computer's going to sleep after 3 minutes"
The WM_TIMECHANGE message is not sent to any programs just because a number of seconds or minutes have passed. It is only broadcasted when a user has changed the date/time settings.
The ExitWindowEx API function can be used to logg off/shut down the computer.
-
Re: "This computer's going to sleep after 3 minutes"
Why not just move the computer out of her room? :)
-
Re: "This computer's going to sleep after 3 minutes"
Using:
Will give the user 45 seconds until shutdown. :P (read on another site)
-
Re: "This computer's going to sleep after 3 minutes"
Quote:
Originally Posted by Zach_VB6
Using:
Will give the user 45 seconds until shutdown. :P (read on another site)
Have you tried that on your PC? Seriously, why would anyone want to delete an exe file used by their OS?
-
Re: "This computer's going to sleep after 3 minutes"
Kill() doesn't delete a file...
You just kill the process with Kill.
(Don't ask where MS came up with that name)
-
Re: "This computer's going to sleep after 3 minutes"
Quote:
Originally Posted by Zach_VB6
Kill() doesn't delete a file...
You just kill the process with Kill.
(Don't ask where MS came up with that name)
BZZZZZT. WRONG.
Kill() deletes files.
chem
-
Re: "This computer's going to sleep after 3 minutes"
Quote:
Originally Posted by Zach_VB6
Kill() doesn't delete a file...
You just kill the process with Kill.
(Don't ask where MS came up with that name)
Again have you tried that on your PC? :lol: :lol: :lol: Run the statement as see what happens... You won't be able to delete it cause its in use by your OS.
-
Re: "This computer's going to sleep after 3 minutes"
x.x
From AndreaVB:
Code:
Type PROCESSENTRY32
dwSize As Long
cntUsage As Long
th32ProcessID As Long
th32DefaultHeapID As Long
th32ModuleID As Long
cntThreads As Long
th32ParentProcessID As Long
pcPriClassBase As Long
dwFlags As Long
szexeFile As String * 260
End Type
'-------------------------------------------------------
Declare Function OpenProcess Lib "kernel32.dll" (ByVal dwDesiredAccess As Long, _
ByVal blnheritHandle As Long, ByVal dwAppProcessId As Long) As Long
Declare Function ProcessFirst Lib "kernel32.dll" Alias "Process32First" (ByVal hSnapshot As Long, _
uProcess As PROCESSENTRY32) As Long
Declare Function ProcessNext Lib "kernel32.dll" Alias "Process32Next" (ByVal hSnapshot As Long, _
uProcess As PROCESSENTRY32) As Long
Declare Function CreateToolhelpSnapshot Lib "kernel32.dll" Alias "CreateToolhelp32Snapshot" ( _
ByVal lFlags As Long, lProcessID As Long) As Long
Declare Function TerminateProcess Lib "kernel32.dll" (ByVal ApphProcess As Long, _
ByVal uExitCode As Long) As Long
Declare Function CloseHandle Lib "kernel32.dll" (ByVal hObject As Long) As Long
^^ Module
Code:
Public Sub KillProcess(NameProcess As String)
Const PROCESS_ALL_ACCESS = &H1F0FFF
Const TH32CS_SNAPPROCESS As Long = 2&
Dim uProcess As PROCESSENTRY32
Dim RProcessFound As Long
Dim hSnapshot As Long
Dim SzExename As String
Dim ExitCode As Long
Dim MyProcess As Long
Dim AppKill As Boolean
Dim AppCount As Integer
Dim i As Integer
Dim WinDirEnv As String
If NameProcess <> "" Then
AppCount = 0
uProcess.dwSize = Len(uProcess)
hSnapshot = CreateToolhelpSnapshot(TH32CS_SNAPPROCESS, 0&)
RProcessFound = ProcessFirst(hSnapshot, uProcess)
Do
i = InStr(1, uProcess.szexeFile, Chr(0))
SzExename = LCase$(Left$(uProcess.szexeFile, i - 1))
WinDirEnv = Environ("Windir") + "\"
WinDirEnv = LCase$(WinDirEnv)
If Right$(SzExename, Len(NameProcess)) = LCase$(NameProcess) Then
AppCount = AppCount + 1
MyProcess = OpenProcess(PROCESS_ALL_ACCESS, False, uProcess.th32ProcessID)
AppKill = TerminateProcess(MyProcess, ExitCode)
Call CloseHandle(MyProcess)
End If
RProcessFound = ProcessNext(hSnapshot, uProcess)
Loop While RProcessFound
Call CloseHandle(hSnapshot)
End If
End Sub
^^ Form.
Use KillProcess (lsass.exe)
-
Re: "This computer's going to sleep after 3 minutes"
I think Kill() in that sense is some script command or possibly a resource kit .com/.exe file. But running it in VB, hopefully, VB's Kill will error if file is in use.
-
Re: "This computer's going to sleep after 3 minutes"
Quote:
Originally Posted by Zach_VB6
x.x
From AndreaVB:
Code:
Type PROCESSENTRY32
dwSize As Long
cntUsage As Long
th32ProcessID As Long
th32DefaultHeapID As Long
th32ModuleID As Long
cntThreads As Long
th32ParentProcessID As Long
pcPriClassBase As Long
dwFlags As Long
szexeFile As String * 260
End Type
'-------------------------------------------------------
Declare Function OpenProcess Lib "kernel32.dll" (ByVal dwDesiredAccess As Long, _
ByVal blnheritHandle As Long, ByVal dwAppProcessId As Long) As Long
Declare Function ProcessFirst Lib "kernel32.dll" Alias "Process32First" (ByVal hSnapshot As Long, _
uProcess As PROCESSENTRY32) As Long
Declare Function ProcessNext Lib "kernel32.dll" Alias "Process32Next" (ByVal hSnapshot As Long, _
uProcess As PROCESSENTRY32) As Long
Declare Function CreateToolhelpSnapshot Lib "kernel32.dll" Alias "CreateToolhelp32Snapshot" ( _
ByVal lFlags As Long, lProcessID As Long) As Long
Declare Function TerminateProcess Lib "kernel32.dll" (ByVal ApphProcess As Long, _
ByVal uExitCode As Long) As Long
Declare Function CloseHandle Lib "kernel32.dll" (ByVal hObject As Long) As Long
^^ Module
Code:
Public Sub KillProcess(NameProcess As String)
Const PROCESS_ALL_ACCESS = &H1F0FFF
Const TH32CS_SNAPPROCESS As Long = 2&
Dim uProcess As PROCESSENTRY32
Dim RProcessFound As Long
Dim hSnapshot As Long
Dim SzExename As String
Dim ExitCode As Long
Dim MyProcess As Long
Dim AppKill As Boolean
Dim AppCount As Integer
Dim i As Integer
Dim WinDirEnv As String
If NameProcess <> "" Then
AppCount = 0
uProcess.dwSize = Len(uProcess)
hSnapshot = CreateToolhelpSnapshot(TH32CS_SNAPPROCESS, 0&)
RProcessFound = ProcessFirst(hSnapshot, uProcess)
Do
i = InStr(1, uProcess.szexeFile, Chr(0))
SzExename = LCase$(Left$(uProcess.szexeFile, i - 1))
WinDirEnv = Environ("Windir") + "\"
WinDirEnv = LCase$(WinDirEnv)
If Right$(SzExename, Len(NameProcess)) = LCase$(NameProcess) Then
AppCount = AppCount + 1
MyProcess = OpenProcess(PROCESS_ALL_ACCESS, False, uProcess.th32ProcessID)
AppKill = TerminateProcess(MyProcess, ExitCode)
Call CloseHandle(MyProcess)
End If
RProcessFound = ProcessNext(hSnapshot, uProcess)
Loop While RProcessFound
Call CloseHandle(hSnapshot)
End If
End Sub
^^ Form.
Use KillProcess (lsass.exe)
It can't be terminated, AppKill = False. In task manager you'll get the reply "access is denied".
-
Re: "This computer's going to sleep after 3 minutes"
-
Re: "This computer's going to sleep after 3 minutes"
Quote:
Originally Posted by Zach_VB6
AppKill is an Integer...
Dim AppKill As Boolean
Regardless of teh data type, bottom line it doesn't work. No point in lengthening the discussion over this.
-
Re: "This computer's going to sleep after 3 minutes"
Quote:
Originally Posted by leinad31
Why not just move the computer out of her room? :)
It's already out, in the library, but she clings to it like a limpet ;)
I really love your touch of humor :)
-
Re: "This computer's going to sleep after 3 minutes"
Quote:
Originally Posted by Joacim Andersson
...
The ExitWindowEx API function can be used to logg off/shut down the computer.
I'm not sure where the final truth lies in this thread, I've only gone through the posts very quickly.
ExitWindowEx seems to be what I was groping for. The question is, can it be used to 'change users' (Windows/L) ? Because it just struck me that some applications such as Antivirus or similar stuff may be running at that time so I woulnd't have the computer shut down after all.
-
Re: "This computer's going to sleep after 3 minutes"
I have a sneaking suspicion that you may be about to embark on a complex (but interesting) exercise that will perform as you desire for about a week - if you're lucky.
First time the automatic shutdown / logoff happens, Daughter mentions it to School friends. School friends show her how to power-up, go into BIOS settings and change the Time of Day........
I don't think that technology is a long term solution to your problem. Getting her out of the Library and locking the door might be simpler. :)
-
Re: "This computer's going to sleep after 3 minutes"
Quote:
Originally Posted by Doogle
I have a sneaking suspicion that you may be about to embark on a complex (but interesting) exercise that will perform as you desire for about a week - if you're lucky.
First time the automatic shutdown / logoff happens, Daughter mentions it to School friends. School friends show her how to power-up, go into BIOS settings and change the Time of Day........
I don't think that technology is a long term solution to your problem. Getting her out of the Library and locking the door might be simpler. :)
Well, these seem to be words of wisdom, indeed. I'll have to think about it.
Perhaps it could be even worse than you suggest. How about changing the time of the day by clicking on the calendar at the tray? Are the API time functions sensible to that?
-
Re: "This computer's going to sleep after 3 minutes"
It may be simpler than you think. XP should have "shutdown.exe" installed in the System32 directory. It allows for a controlled/timed shutdown/logoff with custom messages etc, etc. All you'd really need to do is start it at an appropriate time. Scheduled Tasks ? - maybe a little prog that runs from ...current version\run ? etc, etc - it depends on how much she knows :). For usage, start a command prompt and type "shutdown.exe /?". I'd give more detail, but I've already accidentally logged myself out twice :o
EDIT: Your message could always say it's an automatic shutdown due to an overheated CPU. ROFL
-
Re: "This computer's going to sleep after 3 minutes"
Quote:
Originally Posted by krtxmrtz
Perhaps it could be even worse than you suggest. How about changing the time of the day by clicking on the calendar at the tray? Are the API time functions sensible to that?
If the prog runs at startup, you could store the current time then start a countdown from there. the SetTimer and Killtimer APIs are good for about 25 days.
-
Re: "This computer's going to sleep after 3 minutes"
Why not just use something simple like this:
Code:
Private Sub Timer1_Timer()
If Time > #10:00:00 PM# Then
Shell "Shutdown -s -t 60
MsgBox "This computer will shutdown in 60s",vbokonly,"Auto-Shutdown"
End If
End Sub
Giving 60 seconds before the computer shuts down.
-
Re: "This computer's going to sleep after 3 minutes"
Actually, that will work very well if she's not logged in as admin. Users get a "You do not have the proper privelege level to change the System Time" message if they try to make changes. As long as (as admin) "Automatically synchronize with an Internet time server" is checked in "Date and Time Properties", all it needs is an occasional internet connection to make sure it's reasonbly accurate.
If, on the other hand, it's "HER" PC :) and she's logged in as admin, it may become more complicated. I can see a family crisis looming :D. Over to krtxmrtz....
-
Re: "This computer's going to sleep after 3 minutes"
Quote:
Originally Posted by 03myersd
Why not just use something simple like this:
Code:
Private Sub Timer1_Timer()
If Time > #10:00:00 PM# Then
Shell "Shutdown -s -t 60
MsgBox "This computer will shutdown in 60s",vbokonly,"Auto-Shutdown"
End If
End Sub
Giving 60 seconds before the computer shuts down.
Seems a good idea, all that I'd have to do is maybe add some bells and whistles... Now, if I use Shutdown with the -l switch (rather than -s) to just have it log off the current user, will the program (previously loaded at windows start) remain loaded? If not, can it be loaded at (any) user login?
-
Re: "This computer's going to sleep after 3 minutes"
Just put a key in the registery pointing to the program and it will run, or you can put a shortcut in the startup folder on the start menu.
Code:
Private Sub RegRun()
On Error Resume Next
Dim Reg As Object
Set Reg = CreateObject("Wscript.shell")
Reg.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\MICROSOFT\WINDOWS\CURRENTVERSION\RUN\" & App.EXEName, App.Path & "\" & App.EXEName & ".exe"
End Sub
-
Re: "This computer's going to sleep after 3 minutes"
Quote:
Originally Posted by krtxmrtz
Now, if I use Shutdown with the -l switch (rather than -s) to just have it log off the current user, will the program (previously loaded at windows start) remain loaded? If not, can it be loaded at (any) user login?
If you are asking can you see what your daughter was last messing with after you log her off, I doubt it. When you log off, windows should close all processes and windows. However, you could take a screenshot of the desktop, before starting logoff, and save it to a file (this can be done in code).
-
Re: "This computer's going to sleep after 3 minutes"
If the program is running from HKEY_LOCAL_MACHINE, it should always run, shouldn't it ?
-
Re: "This computer's going to sleep after 3 minutes"
Quote:
Originally Posted by LaVolpe
If you are asking can you see what your daughter was last messing with after you log her off, I doubt it. When you log off, windows should close all processes and windows. However, you could take a screenshot of the desktop, before starting logoff, and save it to a file (this can be done in code).
Well, actually all I mean is to just have her go to bed and get the necessary sleep before the rooster crows.
-
Added difficulty
All this is very nice and my app is about ready, however I've just realized that she may ctrl/alt/del and close the application in this way or kill the process. Is there any means to hide it from the list?
-
Re: "This computer's going to sleep after 3 minutes"
You can not hide it from the Processes tab of the Task Manager but you can hide it from the Application tab by simply setting the App.TaskVisible property to False.
-
Re: "This computer's going to sleep after 3 minutes"
Quote:
Originally Posted by Joacim Andersson
You can not hide it from the Processes tab of the Task Manager but you can hide it from the Application tab by simply setting the App.TaskVisible property to False.
Thanks. This may be sufficient for now. There's always the wilder option of not displaying any warning at all :D
-
Re: "This computer's going to sleep after 3 minutes"
Quote:
Originally Posted by 03myersd
Just put a key in the registery pointing to the program and it will run, or you can put a shortcut in the startup folder on the start menu.
Code:
Private Sub RegRun()
On Error Resume Next
Dim Reg As Object
Set Reg = CreateObject("Wscript.shell")
Reg.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\MICROSOFT\WINDOWS\CURRENTVERSION\RUN\" & App.EXEName, App.Path & "\" & App.EXEName & ".exe"
End Sub
I did but the program didn't seem to be running. It was correctly placed in the registry, I opened it with regedit and it was there all right, but nothing happened and when I looked at the processes by ctrl/alt/del-ing it wasn't listed.
-
Re: "This computer's going to sleep after 3 minutes"
Quote:
Originally Posted by krtxmrtz
I did but the program didn't seem to be running. It was correctly placed in the registry, I opened it with regedit and it was there all right, but nothing happened and when I looked at the processes by ctrl/alt/del-ing it wasn't listed.
Have you rebooted the system?
That key makes programs launch at system startup. So if you have not yet rebooted your system yet you won't feel the difference.
Pradeep :)
-
Re: "This computer's going to sleep after 3 minutes"
hi,
Does she use the PC for internet access only? if so you can restrict access times via the router( if you use one) in most cases, this may be a better way of managing this issue. as a father of an 11 year old i believe a telling off may be the way forward as already stated.
I find that kids are better at getting round these types of things than we are at creating them, I certianly was.
good luck.
David
-
Re: Added difficulty
Quote:
Originally Posted by krtxmrtz
...I've just realized that she may ctrl/alt/del and close the application in this way or kill the process...
You can prevent that with an "Access Denied" message:- http://www.vbforums.com/showthread.php?t=409179
(The little zip there of a .reg file I made has had 20,361 :eek: downloads - or so the forum page says :confused: )
-
Re: "This computer's going to sleep after 3 minutes"
Another suggestion:
Create 2 simple vbs files.
1. The first one contains only a MsgBox to say "Your PC will be shutdown in 3 minutes." Don't care she will close it or not.
2. The second one contains the Shell command "Shutdown /s"
Use Task Scheduler, add:
1. First task runs at 10:00 PM daily to run the first vbs file.
2. Second task runs at 10:03 PM daily to run the second vbs file.
Does this work?
Assumed that she doesn't know how to use task scheduler to cancel a task.
This way her PC won't waste resource to run an App in background with a Timer and prevent her to use Task Manager to kill that App or process.
-
Re: "This computer's going to sleep after 3 minutes"
Quote:
Originally Posted by Pradeep1210
Have you rebooted the system?
That key makes programs launch at system startup. So if you have not yet rebooted your system yet you won't feel the difference.
Pradeep :)
Yes I have.
-
Re: "This computer's going to sleep after 3 minutes"
Quote:
Originally Posted by anhn
Another suggestion:
Create 2 simple vbs files.
1. The first one contains only a MsgBox to say "Your PC will be shutdown in 3 minutes." Don't care she will close it or not.
2. The second one contains the Shell command "Shutdown /s"...
This seems easy enough only how do you shell in a vb file? I think there's no shell command.
-
Re: "This computer's going to sleep after 3 minutes"
Quote:
Originally Posted by Davadvice
hi,
Does she use the PC for internet access only? if so you can restrict access times via the router( if you use one) in most cases, this may be a better way of managing this issue. as a father of an 11 year old i believe a telling off may be the way forward as already stated.
I find that kids are better at getting round these types of things than we are at creating them, I certianly was.
good luck.
David
This option is interesting, but I don't easily find my way around the router configuration. Could you provide a few more details?
-
Re: "This computer's going to sleep after 3 minutes"
he didn't say vb file (which DOES in fact have shell) he said vbs which is visual basic scripting engine. It is similar to vb. Anyway, if you make your program have the same .exe name as a required process she won't know what to delete, if anything. And i think there's some way of making it in the backed up system files so if she ever deletes it the OS restores it automatically.
-
Re: "This computer's going to sleep after 3 minutes"
While I realize that in todays environment this may be a novel concept, try it anyway. It only requires a few (real world) constants to work.
Code:
Option Explicit
Const P As String = "I'm the Parent"
Const C As String = "You're the Child"
You're the parent, so you can figure out the rest of the code!
My Father had to say it only once! There would be NO next time!!
-
Re: "This computer's going to sleep after 3 minutes"
hi,
what type of router do you have ? include the model No and a rough date purchsed. (firmware Revision)
I have had both D_Link and a belkin. these both have the option via the firewall config section to restrict access times on selected IPs.
Please also remember you will need to update the password.
The router manufacturer will have a web site to assist you with this.
I have not tried this myself yet. so i will try when i get home tonight and let you know how i get on
thanks
David
-
Re: "This computer's going to sleep after 3 minutes"
Quote:
Originally Posted by krtxmrtz
I did but the program didn't seem to be running. It was correctly placed in the registry, I opened it with regedit and it was there all right, but nothing happened and when I looked at the processes by ctrl/alt/del-ing it wasn't listed.
Try removing the "On Error Resume Next" and see if anything comes up. 9/10 times if there is a problem with this it is because the user does not have the correct permissions.
-
Re: "This computer's going to sleep after 3 minutes"
Quote:
Originally Posted by Lord Orwell
he didn't say vb file (which DOES in fact have shell) he said vbs which is visual basic scripting engine...
I wrote:
This seems easy enough only how do you shell in a vb file? I think there's no shell command.
...but I actually meant:
This seems easy enough only how do you shell in a vbs file? I think there's no shell command.
-
Re: "This computer's going to sleep after 3 minutes"
Quote:
Originally Posted by CDRIVE
While I realize that in todays environment this may be a novel concept, try it anyway. It only requires a few (real world) constants to work.
Code:
Option Explicit
Const P As String = "I'm the Parent"
Const C As String = "You're the Child"
You're the parent, so you can figure out the rest of the code!
My Father had to say it only once! There would be NO next time!!
Unfortunately things are not always as they used to be when we ourselves were younger. But there's much in what you say.
-
Re: "This computer's going to sleep after 3 minutes"
I'm really glad that you've got as far as you have, as I'm sure you've learnt a lot, but see post #18 (Hopefully, I'm wrong) :D
-
Re: "This computer's going to sleep after 3 minutes"
Quote:
Originally Posted by krtxmrtz
I wrote:
This seems easy enough only how do you shell in a vb file? I think there's no shell command.
...but I actually meant:
This seems easy enough only how do you shell in a vbs file? I think there's no shell command.
ok well the command is not shell in vbscript. Here's how it's done in vbscript:
Code:
Set WshShell = CreateObject("WScript.Shell")
WshShell.Run "C:\WINDOWS\system32\shutdown.exe placeparametershere"
on a side note: If you use "kill" on a file and it invokes shutdown dialog, it's because you did in fact delete the file, and windows needs to restart to fix the mistake you just made by copying it from the protected files directory.
-
Re: "This computer's going to sleep after 3 minutes"
Quote:
Originally Posted by Davadvice
hi,
what type of router do you have ? include the model No and a rough date purchsed. (firmware Revision)
...
All right, I'll stand by. In the meantime: it's a D-Link, model DSL-G624T, purchased June 2007.
-
Re: "This computer's going to sleep after 3 minutes"
Quote:
Originally Posted by Doogle
I'm really glad that you've got as far as you have, as I'm sure you've learnt a lot, but see post #18 (Hopefully, I'm wrong) :D
Actually, by the same token she might learn some lock picking... :lol:
-
Re: "This computer's going to sleep after 3 minutes"
Quote:
Originally Posted by Lord Orwell
ok well the command s nt shell in vbscript. Here's how it's done in vbscript
:
Code:
Set WshShell = CreateObject("WScript.Shell")
WshShell.Run "C:\WINDOWS\system32\shutdown.exe placeparametershere"
Thanks, oh Lord! Now all I have to do is work a little bit on the interface of that msgbox, e.g. allowing bypass of the logoff code by means of a password, lest I should fall into my own trap :D
-
Re: "This computer's going to sleep after 3 minutes"
Quote:
Originally Posted by krtxmrtz
This seems easy enough only how do you shell in a vb file? I think there's no shell command.
This is the code in a VBS (VB Script) file that can shutdown Windows when run, that uses Shell32.dll command:
Code:
Dim oShell
Set oShell = CreateObject("Shell.Application")
oShell.ShutdownWindows
-
Re: "This computer's going to sleep after 3 minutes"
Quote:
Originally Posted by krtxmrtz
Thanks, oh Lord! Now all I have to do is work a little bit on the interface of that msgbox, e.g. allowing bypass of the logoff code by means of a password, lest I should fall into my own trap :D
well, with a running timer displayed of, say, three minutes, this gives you plenty of time to run this from a command prompt:
which aborts the shutdown operation :D
-
Re: "This computer's going to sleep after 3 minutes"
As far as I know, tasks scheduled by one user are hidden from other users. But if I schedule a session logoff, is that going to have effect on my own session only?
-
1 Attachment(s)
Re: "This computer's going to sleep after 3 minutes"
In the meantime, here's what I've been doing. After the app has been compiled, it should be scheduled to run at a certain time and keep trying every 5 minutes, in case the computer was down at the scheduled time. Aside from this, the password should be somewhat encrypted, I'll implement the code as soon as possible.
Still I haven't had a chance to try if it kicks out the current user, as it will be scheduled by another user (the administrator = me)
-
Re: "This computer's going to sleep after 3 minutes"
Quote:
Originally Posted by krtxmrtz
...
Still I haven't had a chance to try if it kicks out the current user, as it will be scheduled by another user (the administrator = me)
Now, it turns out it doesn't even run when I schedule it in my own session. Of course, it does run if I double-click on the compiled app. But I just thought, is it necessary to pack it for distribution and install it from that pack?
-
Re: "This computer's going to sleep after 3 minutes"
-
Re: "This computer's going to sleep after 3 minutes"
Quote:
Originally Posted by krtxmrtz
Now, it turns out it doesn't even run when I schedule it in my own session. Of course, it does run if I double-click on the compiled app. But I just thought, is it necessary to pack it for distribution and install it from that pack?
Scheduled Tasks are user specific. So tasks scheduled from one user account won't run from another. You should login from that account from which you want the task to run. But then beware that it can be stopped by that user (your daughter in this case). So scheduling is not a full proof method.
Have a nice time finding alternatives. :)
Pradeep
-
Re: "This computer's going to sleep after 3 minutes"
Quote:
Originally Posted by anhn in Post#36
Another suggestion:
...
Use Task Scheduler, add:
...
Assumed that she doesn't know how to use task scheduler to cancel a task.
...
That was the assumption.
Quote:
Originally Posted by Bill Gates for Vista
A scheduled task, by default, runs within the security context of the user who scheduled the task and only runs if that user is logged on when the task is triggered. To modify this, change the settings in the Security options section of the General tab when a task's properties are displayed.
You can select a different user or group account for a task to run under by clicking the Change User or Group button. The button will be titled Change User if your user account is not a member of the Administrators group. User accounts that are not in the Administrators group can only specify a user account for a task to run under.
You can specify that a task should run even if the account under which the task is scheduled to run is not logged on when the task is triggered. To do this, select the radio button labeled Run whether user is logged on or not. If this radio button is selected, tasks will not run interactively. To make a task run interactively, select the Run only when user is logged on radio button.
When the Run whether user is logged on or not option if selected, you may be prompted to supply the credentials of the account when saving the task, regardless of whether you select the checkbox labeled Do not store password or not. If the account is not logged on when the corresponding task is triggered, the service will use the saved credentials to run as the specified account and will have unconstrained use of the resulting token.
If you select the checkbox labeled Do not store password, Task Scheduler will not store the credentials supplied on the local computer, but will discard them after properly authenticating the user. When required to run the task, the Task Scheduler service will use the “Service-for-User” (S4U) extensions to the Kerberos authentication protocol to retrieve the user’s token.
When using S4U the ability of the service to use the security context of the account is constrained. In particular, the service can only use the security context to access local resources.
Notes
If your task requires access to network resources, you cannot use S4U; doing so will cause your task to fail. The only exception is the case where constrained delegation was established between the computers involved in the operation.
S4U functionality is only available within an environment where all the domain controllers (DCs) in the domain are running the Windows Server 2003 or later operating system.
If you are using the S4U functionality, the task will not have access to encrypted files.
If you are using the S4U functionality, make sure the Logon as batch job policy is set for the user. This policy is accessible by opening the Control Panel, Administrative Tools, and then Local Security Policy. In the Local Security Policy window, click Local Policy, User Rights Assignment, and then Logon as batch job.
For more information about the S4U Kerberos extensions, see RFC 1510.
If you select the checkbox labeled Run with highest privileges, Task Scheduler will run the task using an elevated privileges token rather than a least privileges (UAC) token. Only tasks that require elevated privileges to complete their actions should run with elevated privileges. For more information, see User Account Control.
-
Re: "This computer's going to sleep after 3 minutes"
Quote:
Originally Posted by anhn
...Originally Posted by Bill Gates for Vista...
Then it doesn't apply for me as I'm using XP.
-
Re: "This computer's going to sleep after 3 minutes"
hi, had a look here for the user guide for that model of router, it would apear that your router does not have the ability to restrict access at certain times.
I never got the chance to try mine out but will give it a go over the next few days.
Can you not get a babysitter type application? that may be more appropriate for the pc that way you can do more than just shut the PC down.
David