Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
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.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - Automount drives in custom provider

Reply
 
Old 11-25-2007   #1 (permalink)
Staffan Gustafsson


 
 

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 SpecsSystem Spec
Old 11-28-2007   #2 (permalink)
Marco Shaw [MVP]


 
 

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
>
>
I'm not a provider expert. Do you know what kind of events these are?

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 SpecsSystem Spec
Old 11-28-2007   #3 (permalink)
Oisin Grehan


 
 

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
Hi 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 SpecsSystem Spec
Reply

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


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46