Re: Unplug USB device

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: [MS] Scott McNairy (scotmc_at_online.microsoft.com)
Date: 04/07/04


Date: Wed, 7 Apr 2004 10:54:32 -0700

Sorry this is not possible via WMI currently, assuming that by Unplugged you
mean disabling the USB device. However if it was a share on another
computer you could delete the connection to that share.

-- 
[MS] Scott McNairy
WMI Test Engineer
This posting is provided "As Is" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
"Jonas Sackerud" <jonas.sackerud@seaflex.net> wrote in message
news:eqHFXRIHEHA.1268@TK2MSFTNGP12.phx.gbl...
> Please forgive my ignorance... where in the script is the USB device
> unplugged?
>
> Thanks for the sample code Scott. I've already written the functionality I
> need for replication using robocopy.exe. All I need is the code to unplug
> the USB device.
>
> Thanks in advance - Jonas Sackerud
>
> "[MS] Scott McNairy" <scotmc@online.microsoft.com> skrev i meddelandet
> news:4072e78d$1@news.microsoft.com...
> > You can accomplish this with a script:
> >
> > dim bDone
> > bDone = false
> >
> > set oQuerySink = wscript.createObject("wbemscripting.SWbemSink",
"SINK_")
> > set NVS = createObject("WbemScripting.SWbemNamedValueSet")
> > set oContext = createObject("WbemScripting.SWbemNamedValueSet")
> >
> > set svc = getObject("winmgmts:root\cimv2")
> > svc.Security_.AuthenticationLevel = 4
> >
> > svc.ExecNotificationQueryAsync oQuerySink, "Select * From
> > win32_processStopTrace where processName = 'robocopy.exe'", "WQL", 0,
NVS,
> > oContext
> >
> > do while not bDone
> >  wscript.sleep 1000
> > loop
> >
> > set oContext = nothing
> > set NVS = nothing
> > set oQuerySink = nothing
> >
> > sub SINK_OnObjectReady(obj, oContext)
> >
> >  wscript.echo obj.ProcessName
> >
> > end sub
> >
> > sub SINK_OnCompleted(hResult, oErr, oContext)
> >  wscript.echo "OnCompleted for the query sink hr = 0x" & hex(hResult)
> >  bDone = true
> > end sub
> >
> > -- 
> > [MS] Scott McNairy
> > WMI Test Engineer
> > This posting is provided "As Is" with no warranties, and confers no
> rights.
> > Use of included script samples are subject to the terms specified at
> > http://www.microsoft.com/info/cpyright.htm
> >
> > "Jonas Sackerud" <jonas.sackerud@seaflex.net> wrote in message
> > news:%23Kf2FC9GEHA.3288@TK2MSFTNGP12.phx.gbl...
> > > Hoping that someone can help a novice with unplugging a USB device
> > > automatically using VBScript (or any other technique for that matter).
> > >
> > > My issue is this:
> > >
> > > I'm using a USB hard drive for replicating my backup data from a
Win2003
> > SBS
> > > machine. Whenever a plug the hard drive to the computer the
replication
> > > starts using robocopy.exe from Windows Resource Kit.
> > >
> > > If I could manage to automatically unplug the USB hard drive when
> > > replication is finished I got myself a fully automatic process. Equal
> > > functionality to a tape solution but with so much more space capacity
:D
> > >
> > > -- 
> > > Regards - Jonas Sackerud
> > >
> > >
> >
> >
>
>


Relevant Pages

  • Re: Unplug USB device
    ... where in the script is the USB device ... All I need is the code to unplug ... > You can accomplish this with a script: ... > sub SINK_OnObjectReady ...
    (microsoft.public.win32.programmer.wmi)
  • Re: Usb GPS installation problem
    ... But the problem starts when unplugging and and plugging again. ... > can I disable USB device detection when connecting the gps to usb port. ... system will find the right driver. ... stop the device before you unplug it. ...
    (sci.geo.satellite-nav)
  • Re: Unplug USB device
    ... > the systray that handles unplugging of USB devices then (the green fellow ... >> mean disabling the USB device. ... >> Scott McNairy ... >> WMI Test Engineer ...
    (microsoft.public.win32.programmer.wmi)
  • Re: USB devices
    ... No, it will never damage anything in the system: ... >every USB device correct? ... When I hook up my smart card reader to the computer I see the icon ... >>>unplug it from the USB port. ...
    (microsoft.public.windowsxp.general)
  • Re: Unplug or eject hardware
    ... of Windows programmatically rather than by the Tray Icon or the Control Panel hardware wizard? ... Specifically I want to unplug a USB device and wait until I get a signal to say it's ok to remove the device. ...
    (alt.comp.lang.borland-delphi)