Bazooka Posted January 3 Share Posted January 3 I am testing a simple AutoIT script to open dsa.msc (Active Directory Users and Computers). The program opens when I use ShellExecute, but doesn't open when I use Run. I cannot use ShellExecute because I need to use RunAs eventually to open the program as another user. #include <MsgBoxConstants.au3> #include <AutoItConstants.au3> #RequireAdmin Run("C:\Windows\system32\dsa.msc"); Why is AutoIT not opening dsa.msc with the Run command. It is able to open notepad and other programs using Run. Also, is there a way to use ShellExecute to open a program as another user(like RunAs)? Link to comment Share on other sites More sharing options...
Developers Jos Posted January 3 Developers Share Posted January 3 (edited) 11 minutes ago, Bazooka said: Why is AutoIT not opening dsa.msc with the Run command. Simply because that file is not an executable! ShellExecute() is using the command shell to open the file with the default defined application for file extension msc. Run() will work when you define it like: Run(@comspec & " /c C:\Windows\system32\dsa.msc"); Edited January 3 by Jos Bazooka 1 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...
ioa747 Posted January 3 Share Posted January 3 try Run('"explorer.exe" "C:\Windows\system32\dsa.msc"') Bazooka 1 I know that I know nothing Link to comment Share on other sites More sharing options...
Solution Bazooka Posted January 3 Author Solution Share Posted January 3 1 hour ago, Jos said: Simply because that file is not an executable! ShellExecute() is using the command shell to open the file with the default defined application for file extension msc. Run() will work when you define it like: Run(@comspec & " /c C:\Windows\system32\dsa.msc"); ah, I see. This solution is working. Only thing is it is also opening a cmd window. Is there a way I can avoid the cmd window? Link to comment Share on other sites More sharing options...
Bazooka Posted January 3 Author Share Posted January 3 55 minutes ago, ioa747 said: try Run('"explorer.exe" "C:\Windows\system32\dsa.msc"') This works with Run but is not working with RunAs, not sure why. Link to comment Share on other sites More sharing options...
Developers Jos Posted January 3 Developers Share Posted January 3 (edited) 1 hour ago, Bazooka said: Is there a way I can avoid the cmd window? Open the Helpfile for your answer. 1 hour ago, Bazooka said: This works with Run but is not working with RunAs, not sure why. I am not stabbing in the dark as there is no concrete info in this statement, there is not much to go on. Edited January 3 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. Link to comment Share on other sites More sharing options...
Bazooka Posted January 3 Author Share Posted January 3 23 minutes ago, Jos said: Open the Helpfile for your answer. Thanks. Added @SW_HIDE 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