Jump to content

Recommended Posts

Posted

I have tried to write a script that calls bcdedit.exe .

I noticed that the command could not be found, even when using a console like described in the help of autoit.

To investigate this problem I did the following: I wrote a script:

#requireadmin

run("cmd.exe","C:\Windows\System32")

and the I manually open a second cmd.exe via Windows 7 Start Menu.

Both directories are C:\Windows\System32> and both run as "Administrator".

Then I enter "bcdedit.exe" into both windows:

The one started via autoit gives a "not found" error, the manually opened cmd executes bcdedit normally.

I can't understand what's going on here. Can anyone explain it to me? For me, both cmd windows should behave the same way. Note that entering "Path" gives the same output on both. :-(

  • Developers
Posted (edited)

Try:

Run("C:\Windows\System32\cmd.exe","")

You need to provide the full path in the first parameter. Second parameter only defines the WorkDirectory.

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

  • Developers
Posted

Thanks, but sadly this is not working. May you try it yourself?

Tried already before posting:

The command window open fine and when I specify bcdedit.exe it runs fine too.

Try this when you are running x64 version of Win7 and the full version of SciTE4AutoIt4 to force x64 mode:

#AutoIt3Wrapper_UseX64=y
#requireadmin
Run("C:\Windows\System32\cmd.exe","")

The command window open fine and when I specify bcdedit.exe it runs fine too.

Did you check the path in both CMD sessions?

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Posted

Tried already before posting:

The command window open fine and when I specify bcdedit.exe it runs fine too.

Try this when you are running x64 version of Win7 and the full version of SciTE4AutoIt4 to force x64 mode:

#AutoIt3Wrapper_UseX64=y
#requireadmin
Run("C:\Windows\System32\cmd.exe","")

The command window open fine and when I specify bcdedit.exe it runs fine too.

Did you check the path in both CMD sessions?

Solved,thank you! the line was not helping too but it has been the right direction. as scite is running on 32 bit, cmd.exe did too. so I tried to run it without scite and now cmd.exe is 64 bit. bcdedit can be found!
  • Developers
Posted

Solved,thank you! the line was not helping too but it has been the right direction. as scite is running on 32 bit, cmd.exe did too. so I tried to run it without scite and now cmd.exe is 64 bit. bcdedit can be found!

That line will work fine but, as mentioned, you need to have the Full version of SciTE4AutoIt3 installed first. :mellow:

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Posted

I recently wrote a little script for bcdedit.exe on win7 x64 and had no problem calling the program.

; apply bcdedit
$foo = Run(@ComSpec & ' /c bcdedit /create /d "' & $entryName & '" /application bootsector', "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
ProcessWait ($foo,5)
Do
    $line = StdoutRead($foo) & StderrRead($foo)
Until $line = not ""

$id = _StringBetween($line, '{', '}')
RunWait(@ComSpec & ' /c bcdedit /set {' & $id[0] & '} device partition=C:', "", @SW_HIDE)
RunWait(@ComSpec & ' /c bcdedit /set {' & $id[0] & '} path ' & '\plop\plpbtldr.bin', "", @SW_HIDE)
RunWait(@ComSpec & ' /c bcdedit /displayorder {' & $id[0] & '} /addlast', "", @SW_HIDE)

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...