Indigo Rose Software

Professional Software Development Tools

 
+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 15 of 16
  1. #1
    Join Date
    Feb 2012
    Posts
    19

    File.Open Help and Understanding

    Hello,

    I 'm new to AMS and AMS forums. So, sorry for my ignorance as I m not a developer/programmer.


    We use ZCM 11.1 to manage Win 7 Group Policies. Of course, we lock down polcies restricting running CLI, Regedit, MSI and CPL. So, I created a simple app that will use File.RunAs with inputs that populate the admin account so it will run the exe as that account.

    The problem is that File.Runas does not launch CPL, MSI etc., and I don't understand why.
    Is it possible for File.Open to use username and password? If I have 2 inputs one for username and the other for password. The end user would enter the admin account info and when they click a button it would run the MSI, CPL etc., using file.open and username and password?

    Below is the code I used for File.Runas. Can I some how adapt for File.Open? Sorry if this does not make sense. Thanks!

    Code:
    --Get the variables
    
    Path = Input.GetText("Path");
    Username = Input.GetText("Username");
    Password = Input.GetText("Password");
    
    --runs exe files 
    File.RunAs(Path, "", "", SW_SHOWNORMAL, false, Username, Password, "", LOGON_NO_OPTION, nil, nil);
    
    -- Check to see if an error occurred when launching the file.
        error = Application.GetLastError();
    
        -- If an error occurred, display an error message to the user.
        if (error ~= 0) then
            Dialog.Message("Error", _tblErrorMessages[error], MB_OK, MB_ICONEXCLAMATION, MB_DEFBUTTON1);
        end

  2. #2
    Join Date
    Apr 2005
    Location
    São Paulo, Brazil
    Posts
    2,539
    What do you set for "Path" and what is the error message that is displayed? You should know that *.msi files are not executables - instead, they need to be passed as an argument to msiexec.exe ...

    Ulrich
    Last edited by Ulrich; 02-09-2012 at 06:52 PM.

  3. #3
    Join Date
    Feb 2012
    Posts
    19
    Ulrich,

    The Path is a input that I can enter a command (c:\windows\system32\cmd.exe) and it the other input are the username and password. This code works fine for me. I was trying to adapt File.Open to work with username and password so I can run MSI, CPL etc. Make sense?

  4. #4
    Join Date
    Apr 2005
    Location
    São Paulo, Brazil
    Posts
    2,539
    No, what you write does not make much sense. "c:\windows\system32\cmd.exe" is an executable, so you should be able to execute it with File.RunAs(). If that is not happening, it would help if you answer my question regarding the error message you receive.

    File.Open() does not take username and password as parameters, please check the documentation.

    And as I stated before, *.msi and *.cpl are not executables, so you cannot use them as the first parameter in a call to File.RunAs() - instead, call the proper handler and pass these file names as arguments.

    Ulrich

  5. #5
    Join Date
    Feb 2012
    Posts
    19
    Ulrich,

    I know File.RunAS is for executables. What I'm trying to accomplish, is to open MSI & CPL as an administrator. My question is how can I open a CPL & MSI using the administrator username and password. I want to be able to launch those types of files with admin rights. I can easily do this with File.RunAs and was not sure how to do this with File.Open.

    All device are locked down with Group Policies and I wanted to easily launches CPL and MSI with admin rights without unlocking the GPO.

    Thanks!

  6. #6
    Join Date
    Apr 2010
    Posts
    529
    Widget,

    Your confusing Apples & Oranges. What Ulrich said is what you need to do.

    File.RunAs will give you the options/ability to run the Command Prompt as an Elevated User that you are looking for. From the help manual
    Code:
    number File.RunAs ( 
    	string  Filename,
    	string  Args = "",
    	string  WorkingFolder = "",
    	number  WindowMode = SW_SHOWNORMAL,
    	boolean WaitForReturn = false,
    	string  UserName = "",
    	string  Password = "",
    	string  Domain = "",
    	number  LogonFlag = LOGON_NO_OPTION,
    	table   CreationOptions = nil,
    	table   ExtendedErrorInfo = nil )
    Description
    Runs an executable as a different user.
    In your case, once you call File.RunAs to open (c:\windows\system32\cmd.exe) the rest of the arguments (calling the CPL, etc) can be entered as "Arguments" (the second arg in File.RunAs), enter the rest of your username, password, etc (as if you were doing this to start the Command Prompt) and you should be good to go.

    As Ulrich said, to run and *.msi file, you would File.RunAs msieexec.exe and add your *.msi file as an argument.

    Bearing in mind, I normally don't use this, but if you logically work it through it eventually makes sense.

    Cheers,
    MadDogDean

  7. #7
    Join Date
    Feb 2012
    Posts
    19
    MadDogDean,

    I think I understand now. Below is the code I m trying to use. It looks right to me but, I get "File Execution Failed" error. I attached a screen shot of the error. Did I mis something in the code? Thanks all....

    Capture.PNG

    Code:
    --Get the initial variables
    Path = Input.GetText("CMD");
    ARG = Input.GetText("ARG");
    UID = Input.GetText("UID");
    PWD = Input.GetText("PWD");
     
    File.RunAs(Path, ARG, "", SW_SHOWNORMAL, false, UID, PWD, "", LOGON_NO_OPTION, nil, nil);
     
     -- Check to see if an error occurred when launching the file.
        error = Application.GetLastError();
    
        -- If an error occurred, display an error message to the user.
        if (error ~= 0) then
            Dialog.Message("Error", _tblErrorMessages[error], MB_OK, MB_ICONEXCLAMATION, MB_DEFBUTTON1);
        end

  8. #8
    Join Date
    Apr 2010
    Posts
    529
    Widget,

    Is the username *actually* "administrator"? The only time I see a "File execution failed" is if the wrong username/password are entered

    Cheers,
    MadDogDean
    Last edited by MadDogDean; 02-11-2012 at 05:57 PM.

  9. #9
    Join Date
    Apr 2010
    Posts
    529
    Widget,

    Out of curiosity, what version of AMS or you running? In the update for 8.0.7.0, a fix was included that:
    Code:
    New Version Available: 8.0.7.0
    Today (December 5, 2011) we have released a new version of AutoPlay Media Studio (v8.0.7.0).
    Commercial users can download the new full installer from your customer portal.
    ...
    ...
    ...
    Fix: Fixed a bug where the File.RunAs action was not sending one of its arguments properly.
    This is all the details IR provided, but maybe related to your problem??

    Cheers,
    MadDogDean

  10. #10
    Join Date
    Feb 2012
    Posts
    19
    MadDogDean,

    You were right I enter the wrong account. Thanks

    Are you saying to run a CPL file, to call it out in the arguments like so?
    Code:
    File.RunAs("C:\\Windows\\System32\\CMD.exe", "ncpa.cpl", "", SW_SHOWNORMAL, false, "Username", "password", "", LOGON_NO_OPTION, nil, nil);
    Yes, I have the latest update. Thanks

    Update Status Software up to date.
    Installed Version 8.0.7.0
    Latest Version 8.0.7.0
    Maintenance Status
    VALID You have 116 days left in your maintenance plan subscription. You can view the status of your subscription at any time through the customer portal.

  11. #11
    Join Date
    Apr 2010
    Posts
    529
    Quote Originally Posted by Widget View Post

    Are you saying to run a CPL file, to call it out in the arguments like so?
    That's correct Widget. Now you're getting the hang of it.

    Cheers,
    MadDogDean

  12. #12
    Join Date
    Feb 2012
    Posts
    19
    MadDogDean,

    I tried the following code. It opens the CLI but does not open ncpa.cpl. Thoughts?

    Thanks!

    Code:
    File.RunAs("C:\\Windows\\System32\\CMD.exe", "ncpa.cpl", "", SW_SHOWNORMAL, false, "Username", "password", "", LOGON_NO_OPTION, nil, nil);

  13. #13
    Join Date
    Aug 2003
    Posts
    2,427
    I haven't tried it but as the .cpl filename extension should alredy have the correct file association you could probably just run ncpa.cpl directly. Worth trying anyway....

  14. #14
    Join Date
    May 2006
    Posts
    1,443
    a CPL is a DLL file actually , but it is mostly similar to COM objects
    there are several ways to run a CPL application

    here is one of them

    Code:
    File.RunAs(_SystemFolder.."\\rundll32.exe", "shell32.dll,Control_RunDLL ncpa.cpl", "", SW_SHOWNORMAL, false, "Username", "password", "", LOGON_NO_OPTION, nil, nil);

  15. #15
    Join Date
    Feb 2012
    Posts
    19
    Reteset,

    That worked. Did not know CPL's are the same as DLL's. Thanks all for your help!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts