Leo1906 Posted November 14, 2016 Share Posted November 14, 2016 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 More sharing options...
Developers Jos Posted November 14, 2016 Developers Share Posted November 14, 2016 Are you running this in x86 or x64 mode? (AutoIt3.exe or AutoIt3_x64.exe) 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. Link to comment Share on other sites More sharing options...
Leo1906 Posted November 14, 2016 Author Share Posted November 14, 2016 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 More sharing options...
Juvigy Posted November 15, 2016 Share Posted November 15, 2016 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 More sharing options...
legend Posted November 15, 2016 Share Posted November 15, 2016 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") Link to comment Share on other sites More sharing options...
rudi Posted November 23, 2016 Share Posted November 23, 2016 Hello, have a look at this MSDN article: https://msdn.microsoft.com/de-de/library/windows/desktop/aa384187(v=vs.85).aspx 32-bit applications can access the native system directory by substituting %windir%\Sysnative for %windir%\System32. Regards, Rudi. Earth is flat, pigs can fly, and Nuclear Power is SAFE! Link to comment Share on other sites More sharing options...
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