Jump to content
Sign in to follow this  
eri

Convert Bat ../??

Recommended Posts

eri

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.. :P

Local $Win = "WinGhoster"
RunWait (@ComSpec & " /c " & "For /F tokens=3 delims=  %%1 in  ( "' bcdedit.exe /create /application OSLOADER /d ' & $Win "")

error.. :party:

Please.. :mellow:

Share this post


Link to post
Share on other sites
PsaltyDS

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!)

:mellow:


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

Share this post


Link to post
Share on other sites
eri

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!)

:P

How to pause cmd with autoit ?? I want see message in cmd ?? :mellow:

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

Share this post


Link to post
Share on other sites
PsaltyDS

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')

:mellow:

Edit: Missing closing paren

Edited 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

Share this post


Link to post
Share on other sites
eri

#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.... :P:mellow:

Share this post


Link to post
Share on other sites
PsaltyDS

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.

:mellow:


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

Share this post


Link to post
Share on other sites
PsaltyDS

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.

:mellow:


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

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.