Jump to content
Sign in to follow this  

Keystroke in Command Prompt

Recommended Posts


I have put together the script below to format a Thumb Drive when inserted. It works pretty good but I would like to automate it further.  Right now the prompt to hit "enter" stops the process.  I would like the script hit enter. I have tried using the Send("{enter}") command in different lines but it does not seem to work no matter where it put it. I have also tried to pause the script to give the window time to open with the "Sleep" command but also no luck.  Here is the script. If anyone has any ideas I would appreciate it.  Thanks. 

#cs ----------------------------------------------------------------------------

 AutoIt Version:
 Author:         myName

 Script Function:
    Template AutoIt script.

#ce ----------------------------------------------------------------------------
; Script Start - Add your code below here
$DBT_DEVICEARRIVAL = "0x00008000"
GUIRegisterMsg($WM_DEVICECHANGE , "MyFunc")
Func MyFunc($hWndGUI, $MsgID, $WParam, $LParam)
RunWait(@comspec & " /c format/q /v:Hartford E:","")
While 1
$GuiMsg = GUIGetMsg()

usb insert.au3

Share this post

Link to post
Share on other sites



Try the additional option " /y" for format.exe

As well you could use powershell instead of format.exe.



Regards, Rudi.

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.