Group policy screensaver - turn it off!

C

chris_culley

Hi,

I have a rather restricitve group policy set on my machine. I look
after a monte carlo simulation model, written in VBA, which annoying
breaks whenever the screensaver kicks in. They won't let me turn the
screensaver off. I have tried.

I have the following programming tools available:

1. VBA
2. Python compiler

and, er, that's it...

Does anyone know any vba hacks (or at a stretch a python hack) which
could stop my screensaver locking every 15 minutes, breaking my model?

I don't care how it does it - simulate a mouse movement, type a key,
turn the screensaver off... anything - it's becoming desperate!

I found the following in this newsgroup, but not sure it would work
with a group policy screensaver (Don Bardner, original author)...




Private Declare Function SystemParametersInfo Lib "user32" Alias _
"SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long,
_
lpvParam As Any, ByVal fuWinIni As Long) As Long


Sub SetScreenSaver(OnOff As Long)
'From Don Bradner
Dim templong As Long
Const SPI_SETSCREENSAVEACTIVE = 17
Const SPIF_UPDATEINIFILE = 1
Const SPIF_SENDWININICHANGE = 2
templong = SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, OnOff,
ByVal
0&, _
SPIF_UPDATEINIFILE Or SPIF_SENDWININICHANGE)
End Sub


Sub MySub()
SetScreenSaver 0
'your code here
SetScreenSaver 1
End Sub
 
C

chris_culley

Actually, I've just tried that code and it didn't work! Any other
ideas?

Cheers,

Chris
 
C

chris_culley

Thanks for that Bernie, I suspect that the same group policy will
prevent me from installing anything new on the machine, but I'll give
it a try :)

I was looking up the sendinput API call - any view on whether that
would simulate a mouse movement? It looks like it wouldn't be
interpreted as a hardware movement, so wouldn't stop the screensaver
(and associated password protect) kicking in.

Cheers,

Chris
 
N

NickHK

Chris,
A quick bit of testing on my system (W2K), shows that printing anything to
debug prevents the ScreenSaver kicking in.
If you halt the code or the code finishes, then the screen saver starts up,
but surely by then it's not a problem.
Screen saver set to 1 min:

Also, the DoEvents seems necssary if the Screen Saver does kick in to allow
you to get rid of it. Maybe try that first.

'Option Explicit
Private Sub CommandButton1_Click()
Dim arr(1 To 1000000) As Variant

Dim starttime As Date

starttime = Now
For j = 1 To 20
For i = 1 To 1000000
'Just some longish calculation
arr(i) = Rnd() * Asc(Mid(Split("ahsd kjhh")(0), 2, 1)) ^ 3.3
Next
Debug.Print Format(Now() - starttime, "ss")
Erase arr
' DoEvents
Next
End Sub

NickHK
 
N

NickHK

Correction:
Whilst, surprisingly, this did work before (honest), it now seems not to.

NickHK
 
C

chris_culley

Thanks Nick Have to say, this doesn't work for me either
unfortunately! :(

I'm thinking of resorting to a hardware solution - having a rotating
disk against my (optical) mouse!

Cheers,

Chris
 
N

NickHK

Chris,
Whilst this works in preventing the screen saver from starting, its use of
SendKeys is somewhat unpredictable if you intend to continue working with
Windows whilst your simulation is running.
You could add a checkbox to indicate if you are running "Unattended", then
execute the SendKeys code; otherwise there is no point executing it, as your
own activity would prevent the SS from starting.
If you are just clicking a WS button and walking away, this <should> work.

After loking at various other suggestion:
- Registry settings which I assume are not accessible for you
- SwitchDesktop API
- Various mouse/keyboard API
I could not get any to work in my open environment, so I serious doubt they
would work in your environment.

Private Sub CommandButton1_Click()
Dim i As Long, j As Long
Dim arr(1 To 1000000) As Variant

Range("D1").Select

For j = 1 To 20
For i = 1 To 1000000
arr(i) = Rnd() * Asc(Mid(Split("ahsd kjhh")(0), 2, 1)) ^ 3.3
Next

Debug.Print "Run: " & j

Erase arr
DoEvents

Application.ScreenUpdating = True
SendKeys "{F2}"
SendKeys "{ESC}"
Application.ScreenUpdating = False
Next

End Sub

NickHK
 
G

Guest

Create a vb script with the following:

Option Explicit
Dim WSHShell, regVal

Set WSHShell = WScript.CreateObject("WScript.Shell")

regVal = "HKCU\Software\Policies\Microsoft\Windows\Control Panel\Desktop\"
regVal=regVal & "ScreenSaveTimeOut"
WSHShell.RegDelete regVal

regVal = "HKCU\Software\Policies\Microsoft\Windows\Control Panel\Desktop\"
regVal=regVal & "ScreenSaverIsSecure"
WSHShell.RegDelete regVal

Set WSHShell=Nothing
 
N

NickHK

Ralph,
Unless I'm missing something, if the group policy bars the OP from changing
the settings manually, how will the OP have permission to those keys ?

NickHK
 
G

Guest

Where I work you can't even open the registry with the policy they have set,
but they can't block you from deleting the keys. The only problem I see with
this solution is every time the policy is implemented the script would need
to be re-run or it could be part of the Excel macro.
 
H

Hiker123

Maybe try a web based MonteCarlo simulation
instead of Excel based.

Try VanguardSystem from Vanguard Software
The thing is Web based, and I believe you can even run
on their servers so you can do an end run around any
policies on local machines. It's also a whole lot faster
than Excel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top