none
Need script to run command line as administrator RRS feed

  • Question

  • I need a VB Script to run a certain command line "wmic Product where name='XXX XXX XXX' call uninstall" in an elevated command prompt.

    This is to uninstall a hidden application.

    Is this possible? It must be I have see many others with suggestions and here it is. I tried a few I have seen but have not been able to get any to work.

    Wednesday, December 17, 2014 8:16 PM

Answers

All replies

  • Are you asking if you can bypass the UAC prompt?

    If that's the question, the answer is no.

    If that's not the question, please ask a clearer question.


    -- Bill Stewart [Bill_Stewart]

    Wednesday, December 17, 2014 8:32 PM
    Moderator
  • Bill,

    Thank you for the quick answer. I believe you are right in your assumption.

    I have been searching but found nothing so far.

    I need to be able to run this line "wmic Product where name='XXX XXX XXX' call uninstall" 

    in an elevated command prompt to uninstall the program.

    I was looking for a VB script or PowerShell to execute it remotely on non domain roaming PCs.

    Wednesday, December 17, 2014 9:38 PM
  • You cannot bypass the UAC prompt, and this is by design.

    FAQ: Why can't I bypass the UAC prompt?


    -- Bill Stewart [Bill_Stewart]

    Wednesday, December 17, 2014 9:54 PM
    Moderator
  • Bill,

    Thank you for the quick answer. I believe you are right in your assumption.

    I have been searching but found nothing so far.

    I need to be able to run this line "wmic Product where name='XXX XXX XXX' call uninstall" 

    in an elevated command prompt to uninstall the program.

    I was looking for a VB script or PowerShell to execute it remotely on non domain roaming PCs.

    Th3e command can be run remotely against stand-alone workstations but you must supply credentials.  Post in the platform forum for you version of Windows for help in using the WMIC utility.  WMIC /? will give you all of the command options fro remote execution.  UAC only affects local systems.  You cannot use WMIC to remote back to the local system. WMIC does not allow impersonation to the local system.

    Most installers will not automatically allow an unattended uninstall.  If there is any dialog at all the uninstall will fail and can hang.

    I recommend contacting the vendor of the application to get more information.

    In all cases you cannot bypass UAC as Bill has noted.  I am only noting that, sometimes, in a workgroup, you can use WMIC to remotely uninstall an application.


    ¯\_(ツ)_/¯

    Wednesday, December 17, 2014 11:05 PM
  • The Vendor has no other solution than to manually running cmd as admin and run the wmic command given. This works but looking to automate it.

    Do you think posting this on the Win 7 and 8 forums will provide me with any solution we can use?

    The Vendor also noted that we can run the manual exe setup file and choose remove.

    If there is a some sort of a script that can do that for us that would be great.

    Friday, December 19, 2014 2:22 PM
  • What's to automate. It is one line to type. Put it in a batch file.

    There is no magic script to solve your problem.


    ¯\_(ツ)_/¯

    Friday, December 19, 2014 2:50 PM
  • Yes I know it is one line and have tried everything with my limited knowledge of scripting and elevating.

    Batch does not work, has to run as admin.

    90 roaming PCs that are on and off all sorts of hours needs to run when PCs check in online with our monitoring service.

    Thanks for getting back to me so quick though

    Friday, December 19, 2014 3:28 PM
  • You cannot bypass the UAC prompt, and this is by design.

    FAQ: Why can't I bypass the UAC prompt?

    Please read this carefully to understand why it is not possible to bypass the UAC prompt.


    -- Bill Stewart [Bill_Stewart]

    Friday, December 19, 2014 3:33 PM
    Moderator