Page 1 of 1

Error while detecting all drives connected to the PC

PostPosted: Thu Jul 25, 2013 5:13 pm
by PaulTomo
Hello All,

I have not been here for some time, but have recently stumbled across an issue that seems to only show up once the NB pub has been compiled and then run on a Windows 7 system that has a multi card reader attached.

The issue I'm getting is when I need to generate a list of drives that are connected to the PC so the NB pub can locate a device once its been connected.
This piece of code works well, so has been created as a function, I simply call the function and it does just what I need.

Code: Select all
SetVar "[DriveList]" "CDEFGHIJKLMNOPQRSTUVWXYZ"
StrLen "[DriveList]" "[DriveListLen]"
Loop "1" "[DriveListLen]" "[Cnt]"
    SubStr "[DriveList]" "[Cnt]" "1" "[DriveLetter]"
    FileList "[DriveLetter]:" "" "[FileData]"
        If "[LastError]" "=" ""
           Math "[DriveNum]+1" "" "[DriveNum]"
           SetVar "[Arrayofdrives[DriveNum]]" "[DriveLetter]:"
        Endif
EndLoop


I have also used the following plugin to see if this would fix my issue.

Code: Select all
rlGetAllDisk "[Arrayofdrives]" "[DriveNum]"


Both the options above work fine during debug mode but once compiled and then run live, although all the connected drives are listed okay and the NB pub can locate a device once its been connected as I want it too, so I know the code is not at fault but if there is multi card reader connected that has any empty slots, I get a repeating error, I think it is generated by Windows and it states:

There is no disk in the drive. Please insert a disk into drive
\Device\Harddisk2\DR2


With options to Cancel, Try Again and Continue.

I can click any of the options and the pub then continues until the next empty slot is detected and so on until all drive letters have been added to the array.

Now that my issue has been detailed, on to my question. (Note: NeoBook v5.8.4 is being used)

Is there anything I can do, apart from making sure all the multi card reader slots are not empty! to stop this error from appearing all the time? Its a little annoying when it appears 7 or 8 times each time the function is used.

Any Thoughts :!:

Many Thanks for your time and hopefully someone may have a solution that will help. :)

Paul

Re: Error while detecting all drives connected to the PC

PostPosted: Fri Jul 26, 2013 1:03 am
by CN_Iceman
Check npDriveType command included in the npUtil plugin from David Esperalta.
http://neoplugins.com/?help/nputil#npDriveType

All my problems with drive units have been fixed after using this command. The idea is to know the type of drive and if sdcard type, skip verification.

Greetings.

Re: Error while detecting all drives connected to the PC

PostPosted: Fri Jul 26, 2013 2:12 am
by dec
Hello,

Maybe my npNots plugin can be useful here too, since they can advise when a new drive is detected, without know if the drive previously exists or not.

P.D. Thanks Jose. ;)

Re: Error while detecting all drives connected to the PC

PostPosted: Fri Jul 26, 2013 4:25 am
by Cipolla
Paul, please try the following VBScript function that i used in a project to get a list of all ready drives. I use it on a Windows 7 machine.

function (copy to your function folder, name it i.e "drivelist")

Code: Select all
{NeoBook Function}
Version=5,80
Language=VBScript
Param=[%1]|Variable|DriveList
{End}
Dim AllDrives
Dim Drive
Set AllDrives = CreateObject("Scripting.FileSystemObject")
For Each Drive In AllDrives.Drives
  If Drive.IsReady Then
    DriveList = DriveList & Drive.Path & ";"
  End If
Next
DriveList = left(DriveList, len(DriveList) - 1)
   
publication.nbSetVar "[%1]", DriveList


And in your publication:

Code: Select all
Call "drivelist" "[Result]"
StrParse "[Result]" ";" "[drives]" "[drives_count]"

Re: Error while detecting all drives connected to the PC

PostPosted: Fri Jul 26, 2013 11:51 am
by CN_Iceman
This is a nice "non-plugin" solution.
Tested and working properly.

Thank's Cipolla.

Re: Error while detecting all drives connected to the PC

PostPosted: Tue Jul 30, 2013 11:31 am
by PaulTomo
Many Thanks for your replies, gives me quite a few options to try.

I'll let you know how I get on.

:P

Re: Error while detecting all drives connected to the PC

PostPosted: Tue Jul 30, 2013 4:07 pm
by PaulTomo
Klaus,

your VBScript option was by far the easiest to add, Good Work!

Did just what I needed and no annoying errors show now.

Many Thanks to all!

:D

Re: Error while detecting all drives connected to the PC

PostPosted: Wed Jul 31, 2013 1:11 am
by Cipolla
Paul, I am really pleased to hear that. That´s why i love Neobook and the community.

Many paths leading to a common goal, but there is almost always a solution.

Re: Error while detecting all drives connected to the PC

PostPosted: Wed Jul 31, 2013 4:11 am
by CN_Iceman
Cipolla wrote:Paul, I am really pleased to hear that. That´s why i love Neobook and the community.
Many paths leading to a common goal, but there is almost always a solution.


+1

Re: Error while detecting all drives connected to the PC

PostPosted: Thu Aug 01, 2013 12:07 pm
by mishem
And this code will work in Windows7
Code: Select all
SetVar "[DriveList]" "C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z"
StrParse "[DriveList]" "," "[Drive]" ""
Loop "1" "24" "[i]"
  FolderExists "[Drive[i]]:\" "[Result]"
  If "[Result]" "=" "False"
     ClearVariables "[Drive[i]]"
     Else
     SetVar "[J]" "[J]+1"
     SetVar "[Drive[J]]" "[Drive[i]]"
  EndIf
EndLoop
ClearVariables "[DriveList],[i],[Result],[J]"