Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@Sh1n0g1
Created March 28, 2017 01:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Sh1n0g1/3cbc620a55d0dcbef9beaef7a5470dbd to your computer and use it in GitHub Desktop.
Save Sh1n0g1/3cbc620a55d0dcbef9beaef7a5470dbd to your computer and use it in GitHub Desktop.
Open CD Tray by PowerShell
$MemDef =@"
[DllImport("winmm.dll", CharSet = CharSet.Ansi)]
public static extern int mciSendStringA(
string lpstrCommand,
string lpstrReturnString,
int uReturnLength,
IntPtr hwndCallback
);
"@
$winmm = Add-Type -memberDefinition $MemDef -ErrorAction 'SilentlyContinue' -passthru -name mciSendString
$winmm::mciSendStringA("set cdaudio door open", $null, 0,0)
#Got a hint from http://stackoverflow.com/questions/3797141/programmatically-opening-the-cd-tray
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment