3

I'm new to coding and I have never used Visual Basic before.

I was asked to write a script that ejects the USB drive.

Public sub cmdClose_Click()
    'CreateObject("Shell.Application").NameSpace("E:").Self.InvokeVerb "Eject"
End Sub

The above script that I found works on Windows 7 but not on XP.
If someone could give me an example of how to eject on Windows XP, that would be great.

StayOnTarget
  • 11,743
  • 10
  • 52
  • 81
P4aszk4
  • 31
  • 1
  • 1
    What’s their excuse for running XP in 2022? – Dai Mar 08 '22 at 11:20
  • According to this answer https://stackoverflow.com/questions/85649/safely-remove-a-usb-drive-using-the-win32-api#answer-85678, there are some CLI tools to do it. This might be simpler in the long run than trying to implement the link to the CodeProject article on the same page. You could place it in the same folder as your `.exe` file, and simply use `Shell "sync -e F:"` or something similar. – User51 Mar 08 '22 at 14:02
  • 1
    Some of the verbs in Windows are localizable. Is your XP using Polish UI language pack? – wqw Mar 08 '22 at 16:14
  • @Dai They could be using legacy software that requires XP. My dad still uses an ancient stock market trading program which runs on XP. – Felix An Apr 03 '22 at 03:20

0 Answers0