WOL on target which can't be reached

This is the full script. Please note that the behavior that I described above is consistent it happens all the time.

Option Explicit

' instead of entering the folder.
'
' It works by changing what double-click does when in thumbnails mode for specific folders
' (which you can configure). To play the album, it searches the for an .m3u playlist within
' the folder you double-clicked.
'
' Since this only affects thumbnails mode, the script can be left enabled and your album
' folders can still be managed in details mode normally, while Opus turns into a music
' selection UI when you switch to thumbnails mode in the chosen folders.

' Called by Directory Opus to initialize the script
Function OnInit(initData)
	' Provide basic information about the Script
	initData.name = "DoubleClick NAS"
	initData.version = "1.0"
	initData.desc = "DoubleClick NAS"
	initData.copyright = "(c) 2018 John"
	initData.default_enable = true
	initData.early_dblclk = true


  Dim cmd
  Set cmd = initData.AddCommand
  cmd.name = "NAS DC"
  cmd.method = "OnAlbumDoubleclick"
  cmd.desc = "DoubleClick NAS"
  cmd.label = "DoubleClick NAS"


	Dim vecDefFolders
	Set vecDefFolders = DOpus.NewVector
	' Default folders / example config.
	vecDefFolders.push_back("/profile\Music")
	vecDefFolders.push_back("D:\Audio\Music Albums")

	initData.config.AlbumFolders = vecDefFolders
End Function

' Helper Function
Function IsPathInVector(fsu, path, vecFolders)

	IsPathInVector = False

If (DOpus.vars.Exists("adc")) = True Then
   Exit Function
End If

	
	' Resolve aliases, libraries, etc. to their real/absolute paths.
'	------------
	Dim testPath
'	------------
	For Each testPath in vecFolders
'	-----------
		If ( fsu.ComparePath(path, testpath,"p") ) Then
			IsPathInVector = True
			Exit Function
		End If
	Next

End Function



Function OnDoubleClick(Path)

'  dopus.output Path.Path.LongPath
 
'   if(Path.is_dir = FALSE) then
'     Exit Function
'    End If


	' Cache the FSUtil object, for efficiency.
'   If (Not IsPathInVector(fsu, Path.Path.LongPath, Script.config.AlbumFolders)) Then
'	   OnDoubleClick = False
'	   Exit Function
'   End If

   Dim Result
   Result  = InStr(Path.Path.LongPath,"lib://")
   if(Result = 0) then
      Path.skipfull = true
      OnDoubleClick = False
      Exit Function
   
   End If
   
   Dim NASPCName
   NASPCName = "NAS-PC"
   Dim Execute
   set Execute = DOpus.NewCommand
   Execute.RunCommand("@sync:D:\Software\Scripts\FileFolderCopyMove\Bin\Client\WOLComputerMustBeCompiledInx64Bits.exe " & """" & NASPCName & """")
   Path.skipfull = true

   if(Path.is_dir = FALSE) then
      Exit Function
    End If

OnDoubleClick = False
 
End Function

I tried your script as is (other than changing the command to run Notepad rather than WOLComputerMustBeCompiledInx64Bits) and I can't see any problems.

Double-click a library, Notepad starts. Close Notepad, the folder changes. Double-click a subfolder, Notepad starts. Close Notepad, the folder changes. Go back to the library root, double-click a library, Notepad starts, etc.

No errors and nothing unexpected as far as I can tell.

Maybe post a video if you can so we can see exactly what's you're seeing.

I got the same results as Jon (i.e. everything seems to work fine and as expected), from a slightly cleaned-up test script with some added debugging:

Option Explicit
Function OnInit(initData)
	initData.name = "DoubleClick NAS"
	initData.version = "1.0"
	initData.desc = "DoubleClick NAS"
	initData.copyright = "(c) 2018 John"
	initData.default_enable = true
	initData.early_dblclk = true
End Function

Function OnDoubleClick(doubleClickData)

	DOpus.Output "OnDoubleClick called with doubleClickData.early = " & doubleClickData.early

	doubleClickData.skipfull = true

	if(InStr(doubleClickData.Path,"lib://") = 0) then
		DOpus.Output "OnDoubleClick - Not a library path: " & doubleClickData.Path
		Exit Function
	End If

	DOpus.Output "OnDoubleClick - Library path: " & doubleClickData.Path

	Dim NASPCName, Execute, CmdLine
	NASPCName = "NAS-PC"
	Set Execute = DOpus.NewCommand
	' CmdLine = "@sync:D:\Software\Scripts\FileFolderCopyMove\Bin\Client\WOLComputerMustBeCompiledInx64Bits.exe " & """" & NASPCName & """"
	CmdLine = "@sync:C:\Windows\Notepad.exe"

	DOpus.Output "OnDoubleClick - Running: " & CmdLine

	Execute.RunCommand(CmdLine)

	DOpus.Output "OnDoubleClick - Command completed"
 
End Function

Another idea: you don't have any other scripts (or older copies of the same script) installed which might be conflicting?

Did you try it when the folder was not available? You don't see any errors or problem if the folder is available.

1.Double click on a folder that is not available. It initiate the WOL immediately.
2.Now the server is available because WOL was initiated in step 1
3.Make the server unavailable (put it into sleep state)
4.Double click on a folder that belong to this server. It will introduce the delay and the WOL is initiated only after the delay and it introduces the error

If you try it on folders that are not available and you need my WOL program to completely replicate the problem then please give me an email address so I will be able to email the EXE together with the AHK file so you will not be afraid that maybe it is a virus. You will be able to compile it yourself.

Thanks

No, we can't test that because we don't have networks with unavailable servers. It should be irrelevant though. The script doesn't know anything about your server, it's your WOL app that handles that. Whether it runs your WOL app or Notepad the rest of the script behaves the same.

I think that you don't understand fully the problem. There is nothing to do with my WOL!
If a folder is unavailable the behavior of your program DOpus is the same as before, it is trying to enumerate/find etc the folder. You have seen it yourself with the debug that I showed you. It does not enter the OnDoubleClick function (if it is the second time) it waits for 30 seconds and then it enters the function. Isn't it what you have tried to avoid? It is working the first time and the second time it is waiting for 30 seconds prior to entering the function OnDoubleClick.

Please run the version of the script I posted above, and see what the debug output says in both of your cases. (Wait until after the delay.)

I will try to explain again what is happening.

  1. Restarting Windows 7 from a shutdown state
  2. Run DOpus and Double click on a folder that s not accessible, it immediately launce your notepad or my WOL, so no problem here.
  3. Now the folder is available. Make the server unavailable.
  4. DC on a folder and the delay occurs for 30 seconds. If it launches my WOL then make the server unavailable again. Just make sure that the folder is not accessible
  5. Try to exit DOpus completely
  6. Launch DOpus with a fresh start
  7. Double click on this same folder that is still unavailable it launches the WOL immediately

What you have done to address the problem is fine, but it looks that there is a variable that must be set/reset after the double click occurs. This variable is in the right state when the program starts. But after the first double click the state of this variable is wrong!

This is the following debug info after I run it on a folder that is available and after running it on a folder that is no available:

14-Apr-18 18:03 DoubleClick NAS: OnDoubleClick called with doubleClickData.early = True
14-Apr-18 18:03 DoubleClick NAS: OnDoubleClick - Not a library path: W:\TEMP
14-Apr-18 18:04 DoubleClick NAS: OnDoubleClick called with doubleClickData.early = True
14-Apr-18 18:04 DoubleClick NAS: OnDoubleClick - Library path: lib://Music PCM/?dc509256/MyFolder
14-Apr-18 18:04 DoubleClick NAS: OnDoubleClick - Running: @sync:C:\Windows\Notepad.exe
14-Apr-18 18:04 DoubleClick NAS: OnDoubleClick - Command completed
14-Apr-18 18:05 DoubleClick NAS: OnDoubleClick called with doubleClickData.early = True
14-Apr-18 18:05 DoubleClick NAS: OnDoubleClick - Library path: lib://Music PCM/?dc509256/MyFolder
14-Apr-18 18:05 DoubleClick NAS: OnDoubleClick - Running: @sync:C:\Windows\Notepad.exe
14-Apr-18 18:05 DoubleClick NAS: OnDoubleClick - Command completed

So the script is being called in all cases, but sometimes it is called after the delay happens instead of before it?

Do you have any other scripts active, or just the one you're working on? Another OnDoubleClick script could be causing the item to be built if it gets called first, perhaps.

Yes now you understand me. The script OnDoubleClick and my WOL are called (if it is the second time) after the delay of 30 seconds. The first time it was called immediately. Your method of solving this problem is the right one. It seems to me that a variable has to be set/reset every time there is a double click event so it would resemble the state of your program when it freshly started. There is also the error that I have said about it before. This error only occur the second or third time or etc. . The first time the OnDoubleClick happened there is no error at all.

I don't have any other OnDoubleClick scripts running together with this one.

I really appreciate the time and effort and your collaboration in dealing with this problem. It is 99% solved.

If that is still happening with my cleaned up version of the script (above), what's in the log when that happens?

No it does not happen with your notepad. Only the delay occurred. That is why I said that please fix the problem of the delay and after that I will be able to investigate. Maybe the problem is with my WOL but I highly doubt it because it is external to your program.
Please find the culprit of the delay and fix it and then maybe the problem of the error will disappear as well.

Thank you very much again

JA

Opus doesn't do anything different if it's running your WOL.exe or Notepad.exe, so if that version of the script doesn't have the error then there must be something wrong with the other version of the script (which had a lot of junk code left in it, for example).

You can make my version of the script run your WOL.exe. I'd recommend testing that way to see if the error still occurs, since whatever was causing the error may be involved in the other problem you're seeing.

No the error does not happen but the delay is still happening. After the WOL there is another code that I am running and maybe that is the reason that it is happening. I will be able to test it fully when there will be no delay every time a double click event occurs.

You can try using DOpus.Output to work out where in the script the delay is occurring. But we may have reached the limit of what we are able to do to address what in reality is a fundamental limitation of Windows and your own network configuration.

It does not even enter the OnDoubleClick function on double click. Your program is waiting for 30 seconds before entering to the OnDoubleClick function. So how can I debug it? It is fine the first time and not after that. There is no code of my WOL, I am using Leo's script. It is not windows limitation it is a bug.

If you want, you could generate a process monitor log and send it to us so we can determine what is accessing the server. It might be something unexpected, like hovering over the folder long enough to trigger the tooltip to be generated, or something like that.

But we can't guarantee we can avoid every possibility of anything accessing a path that is being shown in Opus, for hopefully obvious reasons.

Leaving servers online is what most organisations do, and avoids the problem entirely.

OK Fine I will be using Process Monitor to capture the events for you to check. Do I need to filter out events so it would be easier for you to debug it. If yes then please tell me what events I need to capture.