<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.technet.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>How Can I Determine When a Removable Drive Gets Connected?</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2006/02/13/how-can-i-determine-when-a-removable-drive-gets-connected.aspx</link><description>Hey, Scripting Guy! How can I determine when a USB flash drive gets connected? -- PS 
 Hey, PS. OK, we admit it: the Scripting Guys are lazy. (Especially on a Friday, which is the day when we have to write our Monday column.) There might be a way to</description><dc:language>en-US</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title>re: How Can I Determine When a Removable Drive Gets Connected?</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2006/02/13/how-can-i-determine-when-a-removable-drive-gets-connected.aspx#3510175</link><pubDate>Sun, 22 Jul 2012 22:46:03 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3510175</guid><dc:creator>IamMred</dc:creator><description>&lt;p&gt;@Cavrel you can certainly write to the event log. There are two ways in VBScript to do this, one is to use the event provider from WMI, but it is a bit cumbersome. The easy way is to use the logevent method from the wshshell object. There are several articles that talk about this on the Hey Scripting Guy blog.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3510175" width="1" height="1"&gt;</description></item><item><title>re: How Can I Determine When a Removable Drive Gets Connected?</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2006/02/13/how-can-i-determine-when-a-removable-drive-gets-connected.aspx#3510149</link><pubDate>Sun, 22 Jul 2012 01:34:39 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3510149</guid><dc:creator>Cavrel</dc:creator><description>&lt;p&gt;Instead of window appearing how can I have this script write and event entry in windows event log?&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3510149" width="1" height="1"&gt;</description></item><item><title>re: How Can I Determine When a Removable Drive Gets Connected?</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2006/02/13/how-can-i-determine-when-a-removable-drive-gets-connected.aspx#3332563</link><pubDate>Fri, 14 May 2010 06:46:00 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3332563</guid><dc:creator>magic_man</dc:creator><description>&lt;p&gt;very nice ,thanks&lt;/p&gt;
&lt;p&gt;ineed help with this script( ps script)&lt;/p&gt;
&lt;p&gt;it work perfectly with win 7&lt;/p&gt;
&lt;p&gt;but i need it with win xp&lt;/p&gt;
&lt;p&gt;the script:&lt;/p&gt;
&lt;p&gt;*******************&lt;/p&gt;
&lt;p&gt;#Requires -version 2.0&lt;/p&gt;
&lt;p&gt;set-executionpolicy remotesigned&lt;/p&gt;
&lt;p&gt;Register-WmiEvent -Class win32_VolumeChangeEvent -SourceIdentifier volumeChange&lt;/p&gt;
&lt;p&gt;write-host (get-date -format s) &amp;quot; Beginning script...&amp;quot;&lt;/p&gt;
&lt;p&gt;do{&lt;/p&gt;
&lt;p&gt;$newEvent = Wait-Event -SourceIdentifier volumeChange&lt;/p&gt;
&lt;p&gt;$eventType = $newEvent.SourceEventArgs.NewEvent.EventType&lt;/p&gt;
&lt;p&gt;$eventTypeName = switch($eventType)&lt;/p&gt;
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt;1 {&amp;quot;Configuration changed&amp;quot;}&lt;/p&gt;
&lt;p&gt;2 {&amp;quot;Device arrival&amp;quot;}&lt;/p&gt;
&lt;p&gt;3 {&amp;quot;Device removal&amp;quot;}&lt;/p&gt;
&lt;p&gt;4 {&amp;quot;docking&amp;quot;}&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;write-host (get-date -format s) &amp;quot; Event detected = &amp;quot; $eventTypeName&lt;/p&gt;
&lt;p&gt;if ($eventType -eq 2)&lt;/p&gt;
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt;$driveLetter = $newEvent.SourceEventArgs.NewEvent.DriveName&lt;/p&gt;
&lt;p&gt;$driveLabel = ([wmi]&amp;quot;Win32_LogicalDisk='$driveLetter'&amp;quot;).VolumeName&lt;/p&gt;
&lt;p&gt;write-host (get-date -format s) &amp;quot; Drive name = &amp;quot; $driveLetter&lt;/p&gt;
&lt;p&gt;write-host (get-date -format s) &amp;quot; Drive label = &amp;quot; $driveLabel&lt;/p&gt;
&lt;p&gt;# Execute process if drive matches specified condition(s)&lt;/p&gt;
&lt;p&gt;if ($driveLetter -eq 'H:')&lt;/p&gt;
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt;write-host (get-date -format s) &amp;quot; Starting task in 3 seconds...&amp;quot;&lt;/p&gt;
&lt;p&gt;start-sleep -seconds 3&lt;/p&gt;
&lt;p&gt;start-process &amp;quot;c:\windows\system32\launch.bat&amp;quot;&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;Remove-Event -SourceIdentifier volumeChange&lt;/p&gt;
&lt;p&gt;} while (1-eq1) #Loop until next event&lt;/p&gt;
&lt;p&gt;Unregister-Event -SourceIdentifier volumeChange&lt;/p&gt;
&lt;p&gt;********************************** &lt;/p&gt;
&lt;p&gt;this scrip doing :&lt;/p&gt;
&lt;p&gt;auto detect any removable disk or flash memory&lt;/p&gt;
&lt;p&gt;then check that drive letter&lt;/p&gt;
&lt;p&gt;then check if that drive letter matched thgat letter whom i but it&lt;/p&gt;
&lt;p&gt;if that it run bat file&lt;/p&gt;
&lt;p&gt;then close&lt;/p&gt;
&lt;p&gt;plz help me or make new script to do same task on win xp&lt;/p&gt;
&lt;p&gt;thanks v.much&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3332563" width="1" height="1"&gt;</description></item></channel></rss>