Jump to content

dsa.msc opening with ShellExecute() but not opening with Run()


Go to solution Solved by Bazooka,

Recommended Posts

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

  • Developers
Posted (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 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

  • Solution
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

  • Developers
Posted (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 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

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...