locked
Logon Script to run as Administrator RRS feed

  • Question

  • Dears,

    I have a very simple logon script to copy and install a small software, the issue is that users are not local admin to their computers due to which the script does not run, however if I login with a user with local admin power it works just fine.

    Is there a solution to such a case, where we can run the script with admin privileges ?? 

    Regards,


    MCP,MCTS(Vista),MCSA(Messaging)

    Sunday, May 25, 2014 12:30 PM

Answers

  • Hi Siddiqi,

    it is better that you deploy the software via GPO instead of  logon scripts

    http://support.microsoft.com/kb/816102

    http://community.spiceworks.com/how_to/show/8595-deploy-msi-s-through-your-network-with-gpo

    Regards



    • Proposed as answer by Kasper Johansen Tuesday, May 27, 2014 8:05 AM
    • Edited by brascon Tuesday, May 27, 2014 9:00 AM
    • Marked as answer by Frank Shen5 Wednesday, June 4, 2014 2:12 AM
    • Unmarked as answer by Frank Shen5 Wednesday, June 4, 2014 2:13 AM
    • Marked as answer by Frank Shen5 Monday, June 9, 2014 3:38 AM
    Sunday, May 25, 2014 6:14 PM
  • Salam Naveed!

    Logon script will use the user credentials in order to run the tasks which is hidden in the logon scripts. If they have no local admin right they will not be able to install software using this method. Recently I had to deploy a MSI package and I used MSIEXEC command in a start-up script in order to install the application with silent mode and no user interaction. If your package is a MSI package you can use this command in start-up scripts. Please refer to below link for more info:

    An example would be something like this:

    msiexec /i \\192.168.1.1\Softwares\Package.msi

    Another option you have here is to use Run As command. For that reason you must create two scripts. The one which actually does the whole job and copy and install the software. The second one for calling the first script as Administrator but since I have not tested it I am not sure how it will operates. It just came through my mind. You have created your first script which install the software, for the second script you can use something like this:

    echo P@ssw0rd|runas /user:Contoso.com\InstallerUser "\\192.168.1.1\Softwares\FirstScript.bat"

    But keep it mind that this is not a secure solution because if the user is curious enough he may find the local administrator user via RSPO. For more information about run-as command refer to the following link:

    Regards.


    Mahdi Tehrani   |     |   www.mahditehrani.ir
    Please click on Propose As Answer or to mark this post as and helpful for other people.
    This posting is provided AS-IS with no warranties, and confers no rights.


    • Edited by Mahdi Tehrani Sunday, May 25, 2014 4:12 PM
    • Marked as answer by Frank Shen5 Wednesday, June 4, 2014 2:12 AM
    • Unmarked as answer by Frank Shen5 Wednesday, June 4, 2014 2:13 AM
    • Marked as answer by Frank Shen5 Monday, June 9, 2014 3:38 AM
    Sunday, May 25, 2014 4:11 PM
  • Hi Naveed,

    Based on your description, regarding how to make a script run with admin credentials, in order to get more professional help, we can ask for suggestions in the following scripting forum.

    The Official Scripting Guys Forum

    http://social.technet.microsoft.com/Forums/scriptcenter/en-US/home?forum=ITCG

    In addition, the following thread focused on the similar topic and can be referred to as reference.

    How to apply input admin credentials before running batch file

    http://social.technet.microsoft.com/Forums/scriptcenter/en-US/3d32932a-a693-4eae-a25b-90967b2e0491/how-to-apply-input-admin-credentials-before-running-batch-file?forum=ITCG

    TechNet Subscriber Support
    If you are TechNet Subscription user and have any feedback on our support quality, please send your feedback here.

    Best regards,

    Frank Shen

    • Marked as answer by Frank Shen5 Wednesday, June 4, 2014 2:12 AM
    • Unmarked as answer by Frank Shen5 Wednesday, June 4, 2014 2:13 AM
    • Marked as answer by Frank Shen5 Monday, June 9, 2014 3:38 AM
    Wednesday, May 28, 2014 1:40 AM

All replies

  • Salam Naveed!

    Logon script will use the user credentials in order to run the tasks which is hidden in the logon scripts. If they have no local admin right they will not be able to install software using this method. Recently I had to deploy a MSI package and I used MSIEXEC command in a start-up script in order to install the application with silent mode and no user interaction. If your package is a MSI package you can use this command in start-up scripts. Please refer to below link for more info:

    An example would be something like this:

    msiexec /i \\192.168.1.1\Softwares\Package.msi

    Another option you have here is to use Run As command. For that reason you must create two scripts. The one which actually does the whole job and copy and install the software. The second one for calling the first script as Administrator but since I have not tested it I am not sure how it will operates. It just came through my mind. You have created your first script which install the software, for the second script you can use something like this:

    echo P@ssw0rd|runas /user:Contoso.com\InstallerUser "\\192.168.1.1\Softwares\FirstScript.bat"

    But keep it mind that this is not a secure solution because if the user is curious enough he may find the local administrator user via RSPO. For more information about run-as command refer to the following link:

    Regards.


    Mahdi Tehrani   |     |   www.mahditehrani.ir
    Please click on Propose As Answer or to mark this post as and helpful for other people.
    This posting is provided AS-IS with no warranties, and confers no rights.


    • Edited by Mahdi Tehrani Sunday, May 25, 2014 4:12 PM
    • Marked as answer by Frank Shen5 Wednesday, June 4, 2014 2:12 AM
    • Unmarked as answer by Frank Shen5 Wednesday, June 4, 2014 2:13 AM
    • Marked as answer by Frank Shen5 Monday, June 9, 2014 3:38 AM
    Sunday, May 25, 2014 4:11 PM
  • Hi Siddiqi,

    it is better that you deploy the software via GPO instead of  logon scripts

    http://support.microsoft.com/kb/816102

    http://community.spiceworks.com/how_to/show/8595-deploy-msi-s-through-your-network-with-gpo

    Regards



    • Proposed as answer by Kasper Johansen Tuesday, May 27, 2014 8:05 AM
    • Edited by brascon Tuesday, May 27, 2014 9:00 AM
    • Marked as answer by Frank Shen5 Wednesday, June 4, 2014 2:12 AM
    • Unmarked as answer by Frank Shen5 Wednesday, June 4, 2014 2:13 AM
    • Marked as answer by Frank Shen5 Monday, June 9, 2014 3:38 AM
    Sunday, May 25, 2014 6:14 PM
  • Hi Naveed,

    Based on your description, regarding how to make a script run with admin credentials, in order to get more professional help, we can ask for suggestions in the following scripting forum.

    The Official Scripting Guys Forum

    http://social.technet.microsoft.com/Forums/scriptcenter/en-US/home?forum=ITCG

    In addition, the following thread focused on the similar topic and can be referred to as reference.

    How to apply input admin credentials before running batch file

    http://social.technet.microsoft.com/Forums/scriptcenter/en-US/3d32932a-a693-4eae-a25b-90967b2e0491/how-to-apply-input-admin-credentials-before-running-batch-file?forum=ITCG

    TechNet Subscriber Support
    If you are TechNet Subscription user and have any feedback on our support quality, please send your feedback here.

    Best regards,

    Frank Shen

    • Marked as answer by Frank Shen5 Wednesday, June 4, 2014 2:12 AM
    • Unmarked as answer by Frank Shen5 Wednesday, June 4, 2014 2:13 AM
    • Marked as answer by Frank Shen5 Monday, June 9, 2014 3:38 AM
    Wednesday, May 28, 2014 1:40 AM
  • Hi,

    It's been a while. How is the issue going? If you still need further help regarding the issue, please don't hesitate to let us know.

    Best regards,
    Frank Shen

    Wednesday, June 4, 2014 2:14 AM