Sign in to follow this  
Followers 0
CaptKen

Keystroke in Command Prompt

3 posts in this topic

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: 3.3.14.2
 Author:         myName

 Script Function:
    Template AutoIt script.

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

usb insert.au3

Share this post


Link to post
Share on other sites



Hi.

 

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

Thanks Rudi !! the "/y" did the trick !

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  
Followers 0