6

I'm afraid the answer is "it won't due to new security features", but I'll ask anyway.

I have a USB Flash Drive I run Portable Applications on (who doesn't, right?). I use PStart to start up a nice menu I've been using for a couple years, have my configuration dialed in to something that is productive, so I'm not inclined to just switch to another program.

I have an Autorun.inf in the root of the drive. Its contents:

[Autorun]
Open=Applications\pstart\PStart.exe
Action=Start PortableApps
Icon=Applications\PortableAppsMenu\PortableAppsMenu.exe
Label=PortableApps

When I insert the device on Windows 7, I get prompted to choose from a variety of autostart things I don't want to do:

autorun dialog

It worked fine on XP and Vista, on inserting the PStart.exe would start up and I have menu.

11

Unfortunately, you're correct.

The new security features of Windows 7 will not run autorun programs unless it's on optical media.

See more here: AutoRun changes in Windows 7.

2
  • "...so our customers can benefit..." - People who take security seriously and don't put arbitrary devices in their computers suffer from the inconvenience. I'd like the option to allow specific devices to autorun, even if I have to set it manually the first time :(. – jtimberman Jul 18 '09 at 16:21
  • 4
    Heh. I am of the opposite opinion; autorun is the most evil thing ever invented. I suppose having it do nothing by default would have been a better alternative to removing it completely. – RJFalconer Feb 4 '10 at 22:03
0

This is something I was considering for a previous project and I didn't end up starting it it however my approach would have been to edit the following PowerShell script to run whatever application I wanted, in my case it would be to eject all but specific USB drives. Basically the script monitors the Win32_VolumeChangeEvent table for additions then triggers an application along with some of the event metadata such as drive letter. It could be adapted to run any application or script.

function UsbMountWatcher {
     $alarm = New-Object System.Management.EventQuery
     $alarm.QueryString = "SELECT * FROM Win32_VolumeChangeEvent WHERE EventType = 2"
     New-Object System.Management.ManagementEventWatcher $alarm
}
$pathtompcmdrun = $env:PROGRAMFILES + "\Windows Defender\MpCmdRun.exe"
$watcher = UsbMountWatcher
while ($true) {
     $event = $watcher.WaitForNextEvent()
     $driveletter = $event.Properties["DriveName"].Value.ToString() + "\"
     &$pathtompcmdrun "-Scan" "-File" $driveletter "-DisableRemediation"
     Write-Output $LASTEXITCODE
}
$watcher.Stop()

Source: https://gallery.technet.microsoft.com/Custom-scan-a-USB-drive-17b9be2a

Further reading: https://alitarhini.wordpress.com/2010/11/05/listen-for-removable-device-events/

This should also address the merged but different Windows 10 question: how to automatically run a batch file when USB drive inserted in Windows 10?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.