The chassis is not selected, the CD out/Receive key is blocked, it is awkward to use. Remember that there is a small software can control the optical drive out of the warehouse and the receiving bin. Searched for the Windows API used. Write the following code, I hope you like:
PS c:\users\eden> $a = add-type-memberdefinition @ "
>> [DllImport (" Winmm.dll ", CharSet = CharSet.Ansi)]
>> public static extern int Mcisendstringa (
>> string lpstrcommand,
>> string lpstrreturnstring,
>> int ureturnlength,
>> IntPtr hwndcallback);
>> @-passthru-name mcisendstring
>>
PS c:\users\eden> $a:: Mcisendstringa (' Set CDAudio door Open ', $null, 0,0); # Open Optical drive
0
PS c:\users\eden> $a:: Mcisendstringa (' Set cdaudio door closed ', $null, 0,0); # Turn off Optical drive
0
Finally, we are attaching all the shortcuts in the console that we summarized today for everyone to use PowerShell. These shortcuts are actually supported by Cmd.exe or any console.
Keys |
Function |
← |
The cursor moves one character to the left |
Ctrl + ← |
The cursor moves one word to the left |
→ |
The cursor moves one character to the right |
Ctrl + → |
The cursor moves one word to the right |
Home Key |
The cursor moves to the beginning of the line |
End Key |
The cursor moves to the end of the line |
Delete Key |
Delete the character that the cursor points to |
Backspace Key or Ctrl + H |
Deletes the first character to the left of the cursor |
Ctrl + End Key |
Remove all characters from the cursor to the end of the line |
ESC Key |
Clears all characters that are currently entered |
Insert Key |
Insert and Overwrite mode toggle |
Tab Key |
Tab The key automatically completes the command, for example: the name of the AutoComplete command , cmdlet the parameter and path of the command. If the first prompt is not the result you expect, continuing to enter the Tab Key will automatically display the next candidate. |
↑ |
Query history command up |
↓ |
Query history commands down |
F7 Key |
displays command history, gives all commands you have entered in the form of a graphical list window, and is available the UP and DOWN ARROW keys Select to execute the command again. |
F8 Key |
Search for the history of the command, after entering part of the command on the command, press F8 key, you can get a history command that matches that input. If you have more than one match, press F8repeatedly, and you can loop through all the commands you've entered. If the command behavior is empty, the command that matches all history entries is defaulted. |
F9 Key |
Select a History command by number, which requires you to enter a number for the command (from 0 starts) and displays the command on the screen. |
Enter Key or Ctrl + M |
Carriage return ( Enter ) |
Ctrl + C |
Terminate the currently executing command |
Ctrl + Break |
Terminate the currently executing command |
Alt + F7 Key |
Clears all previously entered command history |