Leo1906

Autoit can't execute exe in System32

6 posts in this topic

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

Share this post


Link to post
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?

Share this post


Link to post
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."

Share this post


Link to post
Share on other sites

if the file is in system32, don't define the full path, but just the name of the file,

anyway, both methods should work. 

ShellExecute("quser.exe")

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