Jump to content

Autoit can't execute exe in System32


Leo1906
 Share

Recommended Posts

Hello there ..

Sometimes I just can't understand Autoit ..
I am trying to execute a simple cmd command, but Autoit refuses to do so.
Here the example script:

Local $iPID = Run(@ComSpec & ' /C quser', @ScriptDir, @SW_HIDE, $STDOUT_CHILD)
ProcessWaitClose($iPID)
Local $sOutput = StdoutRead($iPID)
MsgBox(0, 0, $sOutput)

Other way round:

Local $iPID = Run("C:\Windows\System32\quser.exe", "", @SW_HIDE, $STDOUT_CHILD)
ProcessWaitClose($iPID)
Local $sOutput = StdoutRead($iPID)
MsgBox(0, 0, $sOutput)

Autoit can't "find" the executable. But the path is 100% correct.

Trying other execute commands also fail:

ShellExecute("C:\Windows\System32\quser.exe")

It says it can't find the executable. I don't know why. This is very frustating! The path is 100% correct so it shouldn't be a problem to just execute!

When I copy the exe to desktop and then try my commands with adjustet path all work just fine.
I also tryed with #RequireAdmin but this don't helps either. And it should work without admin rights. Typing quser in a cmd without admin rights works just fine.

So .. can anybody explain that to me? :)

 

Thanks for your help! :)

Link to comment
Share on other sites

In x64 mode.
I now figured out that I need to make a change before executing:

DllCall("kernel32.dll", "boolean", "Wow64EnableWow64FsRedirection", "boolean", 0)

Then it all works. I still don't get why I can't execute a command when I give the exact dir, but this way it works.
This command is the only way when I don't want to make to seperate exe files for x64 and x86, right?

Link to comment
Share on other sites

I guess shellexecute and run fails because of security issues. Most likely autoit doesnt have rights on the sys32 folder . This is why it works when you move it to the desktop.

Look what your DLL call is doing - "This function is useful for 32-bit applications that want to gain access to the native system32 directory. By default, WOW64 file system redirection is enabled."

Link to comment
Share on other sites

  • 2 weeks later...

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
 Share

  • Recently Browsing   0 members

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