![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Automount drives in custom provider Hi, I'm working on a RAPI/ActiveSync provider. It's comming along fine, but I wonder if there is a good way to handle adding/removing a drive when the device connects/disconnects. I get Connect and Disconnect events from RAPI, but I don't see how I go about to mount the drives when that happen. Regards /Staffan |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Automount drives in custom provider Staffan Gustafsson wrote: Quote: > Hi, > > I'm working on a RAPI/ActiveSync provider. It's comming along fine, but I > wonder if there is a good way to handle adding/removing a drive when the > device connects/disconnects. > > I get Connect and Disconnect events from RAPI, but I don't see how I go > about to mount the drives when that happen. > > Regards > > /Staffan > > What are you willing to try/do? I'm not sure if you can use Oisin's PSEventing to respond to the connect/disconnect events: http://www.codeplex.com/PSEventing Marco -- Microsoft MVP - Windows PowerShell http://www.microsoft.com/mvp PowerGadgets MVP http://www.powergadgets.com/mvp Blog: http://marcoshaw.blogspot.com |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Automount drives in custom provider On Nov 25, 5:31 am, "Staffan Gustafsson" <staffan_no_spam_.e.gustafs...@xxxxxx> wrote: Quote: > Hi, > > I'm working on a RAPI/ActiveSync provider. It's comming along fine, but I > wonder if there is a good way to handle adding/removing a drive when the > device connects/disconnects. > > I get Connect and Disconnect events from RAPI, but I don't see how I go > about to mount the drives when that happen. > > Regards > > /Staffan This is a tough one since connect/disconnect events happen asynchronously and as such are serviced by the .net thread pool (not the powershell thread pool). These threads do not have access to the context runspace, so they have no direct way to add new psdrives on demand. Marco suggested using my PSEventing project which would work perfectly well, but you'd have to expose the COM RAPI events publicly, probably as static members on some type loaded by your snapin. PSEventing can bind to these events and it fills a background queue which can be read interactively via my Get-Event cmdlet. The best way to get the effect of a drive getting mounted in pseudo realtime fashion would then be to process these events in powershell's "prompt" function which is executed after every command. However, if you're going to go down that road, it would be probably easier to just create a cmdlet that is designed to be run in the prompt function. This is the route I'm taking in my windows mobile provider. Hope this helps, - Oisin / x0n |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Tab completion\expansion in Custom Powershell Provider | PowerShell | |||
| File Sharing: CUSTOM ? Unable to share drives | Vista networking & sharing | |||
| Testing newly recompile PS custom provider without restarting PS? | PowerShell | |||