Over 300 free and legal portable apps, up-to-date, & new apps weekly (Jun 14, 2013: Opera Mail). Please contribute today!.
PortableApps.com Carbide: Military-grade hardware-encryption, water/shock/dust/tamper-resistant, 5 years antivirus+warranty!
It's safest, most secure USB flash drive on Earth. And it comes with PortableApps.com and your name on it. Starting at $94.95!

PortableApps.com AutoRun/AutoPlay Test 0.1

John T. Haller's picture
John T. Haller
AdministratorDeveloperModerator
(Homepage) - June 2, 2008 - 5:52pm

I've compiled a quick test of some functionality that's part of the next platform release. Specifically, a listener that you can leave running on a local PC to automatically run a PortableApps.com Platform drive when it's inserted.

This is a simple functionality test. It's just a single form that you can run that will tell when a drive is inserted and whether the platform was on it... and if it is automatically start it.

It's designed to be compact and use minimal resources. The EXE is under 200k. When running minimized it uses under 1M of memory. And it uses no CPU resources while sitting around (it waits for Windows to tell it a drive was inserted before doing anything).

When complete, it won't have a form, so it will be smaller. It will probably either just run with no options and have an installer/uninstaller that allows starts/stops it and sets it to autorun or have a tray icon... we'll see. And it'll be released under the GPL.

Give it a shot on multiple operating systems and post your feedback please Smiling
Download PortableApps.com Autorun Test 0.1

How To Test It

  1. Download the EXE to your desktop or any other local drive (this is not a portable app and not supposed to run from a removable drive)
  2. Run the app and leave it open (yes, it stays open... this is just a functionality test)
  3. Insert your removable device
  4. On insert, when Windows detects it, you should see the PortableApps.com Autorun window say the drive letter of the drive once it's insert and whether the platform was found (if StartPortableApps.exe is in the root)
  5. If the Platform is found, it'll automatically run
  6. Windows' autorun box will still appear and ask what you want to do.. you can close it. I haven't added code to suppress it yet.
  7. Insert another drive if you'd like
  8. Close the PortableApps.com Autorun Test window when you're done testing

NOTE: Windows' autorun box will still appear and ask what you want to do.. you can close it. I haven't added code to suppress it yet.

Compatibility

This test app should work on Windows 2000, XP and Vista (and has been verified on all three operating systems). It works with flash drives. (Not sure about removable hard drives at the moment, though, mine isn't here.) And it works from admin, limited and guest accounts.

Hidden Version (No Interface)

This is a special adaptation I added that presents no GUI at all. You can set it to autorun at Windows startup and it should automatically start the PortableApps.com Platform for any drive you plug in. Once you run it, you can stop it from Task Manager... or it should close down as you shut down Windows.

Download PortableApps.com Autorun Test (No GUI) 0.1

Oh, and to prevent the Windows autoplay selection from coming up when you insert your PortableApps.com drive, just hold down the shift key as you plug it in and release it once the menu starts.


( categories: )

didn't do the deed ...

at least I don't think so. I ran the file, it said "Last Drive: None" and "Platform: N/A". The usb was inserted already. I took out the drive, reinserted it, and I got my WinXP popup again with the options of what do I want to do with this usb drive that I have always gotten here.
I ran the file again and I still get the same message of None and N/A.

Don't be an uberPr∅. They are stinky.

On Insert

It only updates when Windows tells it a new drive is inserted. It doesn't yet suppress the Windows autorun dialog.

So, remove your drive. Fire up the autorun test. Then insert your drive. It should show the letter of the drive inserted and then run the platform if StartPortableApps.exe is in the root of that new drive.

Sometimes, the impossible can become possible, if you're awesome!

Yeah I tried that but ...

it didn't work as I envisioned.
I was confused, I had thought that it would actually install a program when I clicked on the file to run in the background. Or is that what you meant about the form?

Okay, so instead I kept the program up and running, and inserted my drive. It did say the correct drive and that the platform has been launched. It didn't automatically start though.

Don't be an uberPr∅. They are stinky.

here the same

here the same

Hell was full, so I came back!!!
Sorry for my lousy English!!!

Same here....

Does it matter where the exe is executed from? If not then nothing happened

An eye for an eye makes the whole world blind.
Mahatma Gandhi,
Indian political and spiritual leader (1869 - 1948)

FAIL

UR DOIN IT RONG. Smiling

I've posted detailed instructions on how it works. It's very simplistic. It's not an installer. And it's not a portable app.

Sometimes, the impossible can become possible, if you're awesome!

It did work for me

But it left the auto run window open. Also had to leave the monitor window open. and this was xp all updates

Expected

This is just a functionality test... so the form stays there (and works for multiple drive insertions). The Windows' autorun is not yet hidden.

Sometimes, the impossible can become possible, if you're awesome!

then it

seems to work as expected.

#5 about autorun ...

it did work! Yaaay! I thought it didn't work because it still brought up the autorun window. Which is fine, as it brought it up, autoran the autorun, and then closed that window. I didn't have to do anything with it except watch it open, run, close.

So, "Works perfectly." Smiling

Don't be an uberPr∅. They are stinky.

Hide autorun window?

Thanks for creating this function, I've been using it for over a year with no problems. Is it possible to update it to disable or hide the autorun window?

Glad to see

Glad to see it's released. Did you use Delphi or NSIS? Where's the source?

Release Team Member

Delphi / Later

It's in Delphi. The source will be released under the GPL later when it's an actual app. This is just a test of the function calls.

Sometimes, the impossible can become possible, if you're awesome!

Later

it looks good

i'm not wierd, i'm just different

Looks good

Looks promising. Smiling

It does its job. Can't wait for a future version that won't need that window and will autostart on Windows startup, though.

"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook

Nice...

We are starting to add platform utilities.
Next up would be an uninstaller, then maybe an app manager that uninstalls, opens help.html's, installs, and manages apps, maybe even compress them. Maybe after that we can make something that Ejects like an ejectscript, then um.. um... I give up, I can't think of anything!

Insert original signature here with Greasemonkey Script.

Works as Expected

This works exactly as expected.

I only have one request/option. Could this be set up so that it could detect any exe. I use PStart because the menu is so minimalistic, so I was hoping that this could eventually include the option to work with any exe. I know that this is going to be integrated into the next platform and I should be using PAM, but hopefully you can make this a little more customizable.

Thanks for all your work.

Probably Not

This is part of the PortableApps.com Platform itself. I've been debating including an option to let it autorun all drives with the appropriate warning that it's not recommended. But there are other closed source solutions out there that let you do this with PStart now, so I don't know that it's necessary.

Sometimes, the impossible can become possible, if you're awesome!

Cool

This sounds mighty mighty cool.

However, I can't find anyone of my 5 flash drives at the moment, so results will have to wait.

Added Hidden Version (No Interface)

For folks who'd like to try it out similarly to the way it's meant to work, I've posted a version that's totally hidden. You can set Windows to autostart it if you'd like.

Sometimes, the impossible can become possible, if you're awesome!

seems

to be working fine i've tested both versions winxp sp3 no problems found

if you don't know-ee you should ASCII

works on win7 ultimate

Thanks for this, works fine for me, but looking forward to the update that closes the default autorun popup.

Man, this thing is great. I

Man, this thing is great. I was about to try something that could possibly break my flash drive right before I found this. Simple and it works.

Wondering if this is still being worked on, looks like it was started back in 2008. A few features I would like to see, the option to pick your file to start since PortableApps.com Platform 10.0 actually uses Start.exe instead of StartPortableApps.exe that this Test is looking for. Or maybe that could even be updated by PortableApps itself just like it does with all the apps for any future changes. Would also maybe like to see the option to automatically close the autorun popup. And don't know if this is possible but once the platform is open have this tools settings be accessible from PortableApps.

works good in vista ultimate sp1

I've tested both the gui and non-gui versions in Vista Ultimate SP1, and it works well. It saw the drive right away and launched the platform right away.

Great!

John, thanks for releasing this program. It will definatly make it easier for those of us who utilize portable HDD's. The functionality appears to be working correctly. I know that this is just a functionality test, but this would be great to include in the suite, but just not installed. It works perfectly for me. I am adding it to my startup menu right now. Thanks again.

Included

It will be included as a tiny installer with the Platform. So, via a menu option, you can setup your PC to use it with just a couple clicks.

Sometimes, the impossible can become possible, if you're awesome!

Failed test (due to the way drive encryption is setup)

Program doesn't detect the platform with the Apricorn Aegis Bio hard drive. This is due to the way the drive works. Upon insertion, the removable drive is detected by Windows (Last drive: does show as "F:"), but the media isn't mounted yet until you swipe your finger to authenticate.

I wonder if other encrypted portable media will behave the same way. If anyone could report if one of those Ironkey's work or any other encrypted portable media. I doubt it since the encryption mechanism need the USB power to function and that's when the drive is detected.

Maybe for these edge cases, you could add an "encrypted drive" option where the program will recheck the detected drive letter every 15 seconds for the platform. Personally, I would have no problem launching the platform myself on an encrypted drive.

Cancer Survivors -- Remember the fight, celebrate the victory!
Help control the rugrat population -- have yourself spayed or neutered!

Hmmm

I bet I could detect that case (drive detected but no files at all) and then sit there for, say, 30 or 60 seconds re-trying the path every second to see if the file exists yet. Would that take care of it?

Sometimes, the impossible can become possible, if you're awesome!

Sounds reasonable, BUT

When I insert my IronKey, the test program doesn't see either the virtual CD partition or the encrypted partition. Before or after unlocking it, with or without pressing Shift. Running fully patched XP Pro SP3.

I've tried everything short of rebooting.  :-)

Last Drive: (none)

Is there a user hook for notification when a volume is mounted?

-hea

P.S. I just tried my old Cruzer Ti 2GB and got the same results... Autorun.inf runs fine if I don't press Shift. (I have AutoPlay NOP'd for all file types on both drives.)

Disable Method

There are two ways to disable AutoPlay. One is to disable it directly. Another involves a registry method which actually disables insert notification to other apps. If you've used the second, we can't tell when a new drive is inserted because Windows won't tell us.

Sometimes, the impossible can become possible, if you're awesome!

Re:

I simply selected the AutoPlay Properties tab and set each file type to "Take no action" (in order to make the AutoRun.inf work).

So, I just Restored Defaults and other than the annoying AutoPlay searching and select windows, same result.

-hea

Your PC

It's something odd on your PC then. I've verified this works properly on two different PCs with 3 operating systems and multiple drives (including U3 ones) and if it's not even getting the drive letter on yours then your OS isn't notifying of drive insertions. What OS? What other firewall software, etc?

Sometimes, the impossible can become possible, if you're awesome!

My PC

XP Pro SP3 w/all patches + ZoneAlarm Security Suite.

It's an old PC, so I can't promise that there's never been some annoying media app that tried to be too helpful with inserted media. What registry values should I look for?

-hea

Here's the ones you need to look into

Cancer Survivors -- Remember the fight, celebrate the victory!
Help control the rugrat population -- have yourself spayed or neutered!

not my PC. Windows!

Thanks BuddaChu for the links. I looked at the values after I got it working.

I've tried everything short of rebooting. Smiling

Finally tried that...  Yay!  Blessings abound and all is right with the world.  Note to self: PC was up continuously for three days. Windows is not Unix. Windows is not Unix.

Test worked flawlessly with the SanDisk. Also worked with the CD volume of the IronKey, but then immediately blurted:

Exception Processing Message c0000013 Parameters 75b6bf9c 4 75b6bf9c 75b6bf9c

After unlocking the IronKey and hitting Retry, it detected the volume and autolaunched PAM.

-hea

Hmmm

Very odd. Looks like the IronKey drive is returning something unexpected. Can you try reinserting it with shift held down (to prevent it from running anything that may mess with the detector). A lot of these two part drives do very nonstandard things. That particular error message is basically the autorun utility trying to check for a removable drive that isn't there... except that Windows just told autorun it's there.

UPDATE: I even tested the detector against a removable card reader... which is basically what these two part drives are supposed to emulate... and it worked fine. Looks like we may need to figure out what it's doing or say it's an unsupported drive in terms of the autorun utility.

Sometimes, the impossible can become possible, if you're awesome!

Interestinger...

With Shift, the detector doesn't detect but the IronKey unlock panel appears. After unlocking, the detector still says "Last drive: (none)".

Then it no longer works even for the SanDisk (which uses a different drive letter) even on different USB port!

I guess successfully unlocking the IronKey sometime since rebooting yet prior to first testing your app made Windows forget how AutoPlay/AutoRun works. At least it didn't blue screen. Windows is not Unix.

I would love to reboot and continue testing, but it'll have to wait. Smiling

-hea

Interestinger Indeed

Interestinger, indeed. Please post back the reboot results. Also, if you could test the utility with your drive on another PC, that would help a lot.

Sometimes, the impossible can become possible, if you're awesome!

ya windows

ya windows sucks that way

it messes things up and it is hard to get them back to normal

but when/if it returns to normal it works great

i'm not wierd, i'm just different

Let's try that

In my case, yes, that would work out well.

John: I thought about making a narrated screen-cap video of what happens when I insert the drive then authenticate. If that could help you, let me know and I can get that done ASAP and posted on my webserver (I'm @ home on vacation). I think I did a decent job describing what's happening though... Eye-wink

Edit: My post is showing up way down here so it's almost outta context. This post is in response to John's idea about detecting a drive letter, but no files (my encrypted drive scenario) then "scanning" for the platform after & over a period of time.

Cancer Survivors -- Remember the fight, celebrate the victory!
Help control the rugrat population -- have yourself spayed or neutered!

Good

No, I think I understand what your drive does. I have a couple ideas to handle it.

Sometimes, the impossible can become possible, if you're awesome!

Great tool, worked well for

Great tool, worked well for me.

A suggestion: If you plan on keeping the GUI, make it a static size, instead of allowing resizing.

The developer formerly known as ZGitRDun8705

temporary for testing

Quote: "When complete, it won't have a form, so it will be smaller"

Try the version linked to at the bottom (no GUI)

Cancer Survivors -- Remember the fight, celebrate the victory!
Help control the rugrat population -- have yourself spayed or neutered!

Yup, that one works too.

Yup, that one works too.

The developer formerly known as ZGitRDun8705

XP SP3 domain user account

works well, holding the shift key suppresses windows autoplay, gui shows detected drive and starts the menu

Edit: XP Pro SP3 admin account : ditto

"Lorem ipsum dolor sit amet, consectetur adipisici elit, sed eiusmod tempor incidunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis .." Friday Next -
"May The Schwartz be with You!" Yogurt the Yoda

Awsome

Works great.
Work computer, Win2K, limited acct.
I'll try it on one of our XP machines later.

Normal portable hard drive works fine

I installed the platform and a few sample portable apps on a NON-encrypted plain old boring portable hard drive. After launching the program you're testing, it was detected as the right drive letter and the PA platform was detected and launched.

WinXP SP2

EDIT: Both the GUI/Form and the noGUI version worked fine.

EDIT2: Both proggies worked fine on another machine with WinXP SP3 (USB 1.1 is a pain to deal with Sad )

Cancer Survivors -- Remember the fight, celebrate the victory!
Help control the rugrat population -- have yourself spayed or neutered!

It works!

It even launched my customized StartPortableApps.exe Laughing out loud

Insert original signature here with Greasemonkey Script.

For Now

The final version will only launch the real one.

Sometimes, the impossible can become possible, if you're awesome!

...

*insert evil laugh here*

Why?

Oh, because of Autorun, right?
Well, mine has all the same details anyway, no way to distinguish other than file size and MD5

Insert original signature here with Greasemonkey Script.

Lol

...and digital signatures. Sticking out tongue

In that case...

Please John! Please let custom startup!!!
(The open source definition says freedom of choice Eye-wink)

Insert original signature here with Greasemonkey Script.

Umm

It's PortableApps.com AutoRun, not Custom AutoRun. If it's really important to you that you have this utility to launch your custom configuration, I'd recommend you use Google and find something else.

"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook

Or when John releases it

Or when John releases it along with it's source, add support for an ini configuration file so one can change what app it launches

The developer formerly known as ZGitRDun8705

if it can be changed ...

I know that I would use it to autolaunch with a tray icon a couple of programs that I run at work that start at startup, just to get rid of the window bar and only have a tray icon.

Don't be an uberPr∅. They are stinky.

You

are quite free not to use it Eye-wink

hmm ..

not if it includes not to use the portableapps.com menu
to manage the portableapps.com autorunning of your
portableapps.com applications on your portableapps.com UFD ..

not working now ...

for some reason. I am not sure if it was new winxp updates or not, but now when I plug in my usb with the program running, it detects the drive, but it also still has the popup window that I must manually choose to run the start portable apps icon.

Don't be an uberPr∅. They are stinky.

hey john, wouldn't this be

hey john, wouldn't this be self promotion, seeming how there isn't the source code available to download?

But there’s no sense crying over every mistake,
You just keep on trying till you run out of cake.

Baha!

Haha, first off, source code is coming when it's finalized. As that would not cut it for most things posted here, I give you this: How can you self promote PortableApps.com on PortableApps.com? Sticking out tongue

Wait 'till John T. Haller hears what John T. Haller's been up to! Sticking out tongue

hmm.... seems we have a

hmm.... seems we have a paradox loop here. quick john, release the source code and stop the paradox loop before its too late! Sticking out tongue

But there’s no sense crying over every mistake,
You just keep on trying till you run out of cake.

A few things

1. How will this be listed in the test releases?
2. Now we have 2 menu launchers
3. If this becomes offical, would we install it to our flashdrives?

The guy who acts like he knows what he's talking about.

Try reading more carefully.

It says it'll be included with the menu, one is gui, one is no gui.
And the Menu will have the installer on board, all of that was on the OP.

Insert original signature here with Greasemonkey Script.

I skimmed through the

I skimmed through the comments and didn't see this. Forgive me if someone has already suggested it, or if it does it already ... would it be possible for it to check the digital signature of the file(s) it is going to run? That would add a layer of confidence that it isn't being used to launch a trojan or something.

This would be for the situation where it is going to run one of the PortableApps.com programs, of course.

MC

Working On It

I'm working on a way for it to do that. The only way I've found is with a commercial package.

At the very least, it will be checking the Company Name, etc. It would still allow a malware writer to spoof it, but it would have to be specifically written to do so. I don't think any of the autorun programs from our competitors (Ceedo, U3, etc) check for digital signatures either.

Sometimes, the impossible can become possible, if you're awesome!

What about a checksum of the

What about a checksum of the file being run?

Nope

StartPortableApps.exe will be changing in subsequent releases as features are added to it.

Sometimes, the impossible can become possible, if you're awesome!

You could use a database or

You could use a database or something which has the checksums of each of the .exe and could use an autoupdater for new versions of the menu

Why?

It would be fairly easier if it was just static and stick features in the menu, right?

Insert original signature here with Greasemonkey Script.

Nope

Some of them have to be offloaded to the Starter.

Sometimes, the impossible can become possible, if you're awesome!

Hm...

There has to be a static property...
*Edit:* Oh I know! We can let the menu autoupdate it...

Insert original signature here with Greasemonkey Script.

...

Wait, huh? Doesn't StartPortableApps.exe just launch the menu? I was under the impression that it was just a glorified shortcut to PortableApps\PortableAppsMenu\PortableAppsMenu.exe... I can definitely say that launching the latter directly doesn't cause any issues, so what exactly does StartPortableApps.exe do?

At The Moment

It's just a shortcut right now, but that will be changing in the 2.0 release as it gains some features that have to be offloaded from the menu.

Sometimes, the impossible can become possible, if you're awesome!

If the checksum were signed,

If the checksum were signed, that would work. But that's pretty much what a detached signature is anyway.

MC

Well, if there's no way to

Well, if there's no way to handle the attached/commercial code signing, perhaps you could have it check a detached GPG/PGP sig? You could do both without too much trouble.

MC

SWEET

This is exactly what I have been wanting
Do you have an Idea when the Final release will be out

Any plan to develop this

Any plan to develop this component in the future? Smiling

2.0

It will be a part of the 2.0 platform, allowing you to install/uninstall it locally with just a click from the menu.

Sometimes, the impossible can become possible, if you're awesome!

found a slight issue because

found a slight issue because i use an external hdd using esata (not my only option but one i thought i would test) windows does not auto run it and to make matters worse it shows up as a local drive so this app will not see the drive as new (because this system has assigned the esata port a reserved drive letter) the app does nothing on this drive. works fine with my other drives

i know u all do your best and i thank you for your patience

As Designed

It's really working as designed. It's only gonna do something when a new drive event is triggered by windows. As your drive is essentially already "there", Windows doesn't trigger a new drive event. Since ESATA is a true outlier (think 0.000001%) as it's not really that portable overall (about the same % of PCs have an external ESATA port) and it would require something more active using the CPU (as opposed to the current passive approach which waits for Windows to trigger it), I don't think we need to worry about special handling for it at the moment.

Sometimes, the impossible can become possible, if you're awesome!

notifiy

Isn't there an API that would notify your app when, say, a file X:\StartPortableApps.exe suddenly appears? You might not want to set a notification for every possible drive letter, but if the configuration knew that drive X: had potential, might it be able to register for a notification there?

Just thinking out loud. Also wondering what Windows does if autoplay is turned off...

MC

Events

You can only tell Windows to notify you when specific events happen. Like DBT_DEVICEARRIVAL.

Sometimes, the impossible can become possible, if you're awesome!

You can also use WMI.

You can also use WMI. Register a WMI Sink with ExecNotificationQueryAsync for a particular device class like Win32_LogicalDisk, then inspect any notifications sent. Off the top of my head I can't remember all the properties available for logical disks, but there may be something there of use. This method is also good because it is just as passive as using Windows notifications.

I'm not sure if you're familiar with AutoIt, but here's an example I have of what I'm talking about -

$wmiSink = ObjCreate("WbemScripting.SWbemSink")
ObjEvent($wmiSink , "SINK_")

$Obj_WMIService = ObjGet('winmgmts:\\localhost\root\cimv2')

If Not @error Then
	$obj_WMIService.ExecNotificationQueryAsync($wmiSink, "SELECT * FROM __InstanceOperationEvent WITHIN 1 WHERE TargetInstance ISA 'Win32_LogicalDisk'")
    ConsoleWrite("Ready and waiting for changes" & @CRLF)
EndIf

While 1
    Sleep(1000)
WEnd

Func SINK_OnObjectReady($objLatestEvent, $objAsyncContext)
	Switch $objLatestEvent.Path_.Class
		Case "__InstanceCreationEvent"
			ConsoleWrite("->==========================================" & @CRLF)
			ConsoleWrite("> Creation Event" & @CRLF)
			
		Case "__InstanceDeletionEvent"
			ConsoleWrite("->==========================================" & @CRLF)
			ConsoleWrite("> Deletion Event" & @CRLF)
			
	EndSwitch
	; Access:
	; 0 - Unknown
	; 1 - Readable
	; 2 - Writable
	; 3 - Read / Write Supported
	; 4 - Write Once
	Switch $objLatestEvent.Path_.Class
		Case "__InstanceCreationEvent", "__InstanceDeletionEvent"
			ConsoleWrite("Access: " & $objLatestEvent.TargetInstance.Access & @CRLF)
			ConsoleWrite("Caption: " & $objLatestEvent.TargetInstance.Caption & @CRLF)
			ConsoleWrite("Description: " & $objLatestEvent.TargetInstance.Description & @CRLF)
			ConsoleWrite("DeviceID: " & $objLatestEvent.TargetInstance.DeviceID & @CRLF)
			ConsoleWrite("DriveType: " & $objLatestEvent.TargetInstance.DriveType & @CRLF)
			ConsoleWrite("FileSystem: " & $objLatestEvent.TargetInstance.FileSystem & @CRLF)
			ConsoleWrite("FreeSpace: " & Int($objLatestEvent.TargetInstance.FreeSpace / 1000000) & " MB" & @CRLF)
			ConsoleWrite("Name: " & $objLatestEvent.TargetInstance.Name & @CRLF)
			ConsoleWrite("Size: " & Int($objLatestEvent.TargetInstance.Size / 1000000) & " MB" & @CRLF)
			ConsoleWrite("VolumeSerialNumber: " & $objLatestEvent.TargetInstance.VolumeSerialNumber & @CRLF)
			ConsoleWrite("->==========================================" & @CRLF)
	EndSwitch
EndFunc   ;==>SINK_OnObjectReady

nope

That API is for watching a directory that already exists for changes to the files in it.

So, if the X: drive was already inserted, you could watch X:\ and see if someone created StartPortableApps.exe using that call, but if the X: drive is not inserted, there is nothing to watch, and, besides, the file is not created, renamed or deleted which is what the API call monitors.

I knew it would work for a

I knew it would work for a directory that exists. I was just hoping it might work for a directory that didn't exist and then suddenly did because the volume was mounted, but I hadn't had a chance to test that possibility, or even research how that API worked in practice.

For example, it would be nice if it could watch for (get notified of) the mounting of a TrueCrypt volume that contained PortableApps, or for the other outliers like eSata volumes that also don't notify as when a USB volume is mounted.

MC

I really don't understand the

I really don't understand the problem y'all are trying to fix (detecting drive insertion), but using the method Wraitdu suggested would be your best bet. Just compare the known drive letters from one instance to another for a change, say check every 1 second. Once a change is detected do [stuff]. Problem is, if the code is on the portable drive itself, the event is triggered *before* the code can run and thereby detect said event. It would need to be resident on the machine or on another removable drive and be running when the drive is inserted.

Within the "sink" mentioned by Wraitdu, put the know drive letters into an array and either check the array for changes or at what position the last drive letter appears. If a new letter appears or the last detected drive letter moved from var(4) to the var(5), you know something happened like a drive was added. then yoyu could scan the new drive and check it's drivetype.

Win32_LogicalDisk Class: http://msdn.microsoft.com/en-us/library/aa394173.aspx

Use the following code to prototype (trimmed down code from Scriptomatic v2.0) using 'cscript' and saving the code as filename.vbs

On Error Resume Next

Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20

arrComputers = Array("ODIN")
For Each strComputer In arrComputers

   Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
   Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_LogicalDisk", "WQL", _
                                          wbemFlagReturnImmediately + wbemFlagForwardOnly)

   For Each objItem In colItems
      WScript.Echo objItem.DeviceID
   Next
Next

Cancer Survivors -- Remember the fight, celebrate the victory!
Help control the rugrat population -- have yourself spayed or neutered!

No

There's no need for any of that. If you register a hook, Windows will TELL you when a drive is inserted. The problem is that for some reason, oddball external ESATA drives don't trigger that hook (not too surprising since the hook pre-dates SATA entirely).

Looping through drives and checking for something every X seconds takes CPU and resources. The right way doesn't.

Sometimes, the impossible can become possible, if you're awesome!

I don't know if the WMI Sink

I don't know if the WMI Sink method works for ESATA drives, I don't have one. But using ExecNotificationQueryAsync DOES NOT cause your application to poll. It registers a notification Sink, like a hook, and the system sends you a notification when there is a change. The WITHIN parameter specifies how often the SYSTEM looks for a change, then notifies your Sink.