eri Posted June 9, 2010 Posted June 9, 2010 How to Convert this Bat File : @echo off set Win="Winpe" For /F "tokens=3 delims= " %%1 in ('bcdedit.exe /create /application OSLOADER /d %Win%') do set guid1=%%1 echo %guid1% pause into AutoIt Script.. My script Always error.. Local $Win = "WinGhoster" RunWait (@ComSpec & " /c " & "For /F tokens=3 delims= %%1 in ( "' bcdedit.exe /create /application OSLOADER /d ' & $Win "") error.. Please..
PsaltyDS Posted June 9, 2010 Posted June 9, 2010 The delimiter needs the literal double quotes around it: Local $Win = "WinGhoster" RunWait (@ComSpec & ' /k For /F "tokens=3 delims= " %%1 in ('' bcdedit.exe /create /application OSLOADER /d ' & $Win & "') do echo %%1") Note single quotes enclosing literal double quotes, doubled single quotes to get a literal single quote. The string appended after $Win is enclosed with double qoutes and includes a literal single quote. (Yes, this stuff can get confusing!) Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
eri Posted June 9, 2010 Author Posted June 9, 2010 The delimiter needs the literal double quotes around it: Local $Win = "WinGhoster" RunWait (@ComSpec & ' /k For /F "tokens=3 delims= " %%1 in ('' bcdedit.exe /create /application OSLOADER /d ' & $Win & "') do echo %%1") Note single quotes enclosing literal double quotes, doubled single quotes to get a literal single quote. The string appended after $Win is enclosed with double qoutes and includes a literal single quote. (Yes, this stuff can get confusing!) How to pause cmd with autoit ?? I want see message in cmd ?? if i run Local $Win = "WinGhoster" RunWait (@ComSpec & ' /k For /F "tokens=3 delims= " %%1 in ('' bcdedit.exe /create /application OSLOADER /d ' & $Win & "') do echo %%1") ;<< 1 RunWait (@ComSpec & ' /k pause') ; << 2 will Open new cmd and pause it.. How to pause cmd in ;<< 1
PsaltyDS Posted June 9, 2010 Posted June 9, 2010 (edited) You don't need a pause if you use " /k " vice " /c " to start the shell. It leaves the shell open after execution until you close it: RunWait (@ComSpec & ' /k DIR') Edit: Missing closing paren Edited June 11, 2010 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
eri Posted June 11, 2010 Author Posted June 11, 2010 #RequireAdmin #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Constants.au3> $Win = "WinGhoster" Local $cmd1 = ' /c @For /F "tokens=3 delims= " %1 in ( '' bcdedit.exe /create /application OSLOADER /d ' & $Win & "') do set guid1=%1" Local $MyRead $PID = Run(@ComSpec & $CMD1, "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 471, 90, 224, 333) $Button1 = GUICtrlCreateButton("Run", 8, 40, 81, 33, $WS_GROUP) $Input1 = GUICtrlCreateInput("", 16, 8, 441, 21) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 $MyRead = StdoutRead($PID) If @error Then ExitLoop GUICtrlSetData($Input1, $MyRead) MsgBox(0, "STDERR read:", $MyRead) EndSwitch WEnd How To Disable $STDERR_CHILD + $STDOUT_CHILD Only Show in $Input1.. In $Input1 = C:\Users\Name\Desktop>set guid1={30a2fe17-73c9-11df-9464-001e33ba0d14} I want delete C:\Users\Name\Desktop>set guid1={} Only Show 30a2fe17-73c9-11df-9464-001e33ba0d14 Please....
PsaltyDS Posted June 11, 2010 Posted June 11, 2010 Your handling of the output makes no sense. Do StdOutRead() outside of the $nMsg cases so you are collecting the results whether $Button1 is hit or not. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
PsaltyDS Posted June 11, 2010 Posted June 11, 2010 Extracting the string you want would just be: $sTxt = "C:\Users\Name\Desktop>set guid1={30a2fe17-73c9-11df-9464-001e33ba0d14}" $sTxt = StringTrimLeft($sTxt, StringInStr($sTxt, "{")) $sTxt = StringLeft($sTxt, StringInStr($sTxt, "}") - 1) ConsoleWrite("$sTxt = " & $sTxt & @LF) It could also be done with StringRegExp() or _StringBetween(), but this is simpler. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now