0
votes

I am getting this error when I am trying to make a custom screensaver. It says: (script location) Line: 20 Char: 4 Error: Expected "If" and when I chane it it also says expected end or something else. The idea is to launch a screensaver I have made in a .bat script and it will detect when to launch it. Also, could I also have some help detecting that the mouse isn't moved for the time specified? Anyway, here is what I have done so far:

set service = GetObject ("winmgmts:")
Dim StartTime, EndTime, Elapsed
StartTime = Timer
Elapsed = Timer - StartTime
If Timer > 100000 Then
for each Process in Service.InstancesOf ("Win32_Process")
If Process.Name = "cmd.exe" then
sleep 0
else
createObject("WScript.Shell").Run "screensaver.bat"
StartTime = 0
EndTime = 0
Elapsed = 0
Timer = 0
end

thanks in advance ~ Dan

2
Can you edit your question and add the source code of your batch file ? - Hackoo
The screensaver isnt done - Lightningblizerd

2 Answers

0
votes

The default If statement is

If True Then
  WScript.Echo "True"
End If

If you delete the If in End If, you get the Expected 'If' error.

In your code you 'open' two Ifs and one For. Close them properly and indent your code.

0
votes

I have updated the script so it launches the screensaver properly, but still doesn't detect idle time and the timer doesn't really work. I changed the script.