run WMIC from query analyzer, acess denied!

Posted on 2005-04-07
Last Modified: 2008-02-01
I tried to run the following sql statement from Query Analyzer,

EXEC master.dbo.xp_cmdshell 'wmic /node:zid3159 service where (name=''JRun Default'') set state=''Running'''

get following error:

Code = 0x80041003
Description = Access denied
Facility = WMI

but it works fine if run the following command-line directly:
wmic /node:zid3159 service where (name='JRun Default') get state

Question by:DataField
    LVL 30

    Expert Comment

    xp_cmdshell runs under either:

    1. SQL Server service account (if your SQL login is a sysadm)
    2. Proxy account (if your SQL Server login is not sysadm)

    Whichever user you are doesn't have permission to run WMIC

    Look up Books online for more info.


    Author Comment

    I user my windows login to logon server (windows 2003) remotely, it is ok I execute it from command prompt. But it doesn't work if I run from query analyzer.

    LVL 30

    Accepted Solution


    You are running your statements under two different users. Thats why it only works one way.

    If you temporarily change the SQL Server Service to domain admin it will work through query analyzer.

    But don't leave the SQL Server Service user as domain admin. Its a security issue.

    LVL 30

    Expert Comment

    Just want to let you know, you want to work the minimum security required for this account, rather than leave it at Administrator.

    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    Join & Write a Comment

    Database tuning – How to start and what to tune. This question is frequently asked by many people, both online and offline. There is no hard and fast rule-of-thumb for performance tuning, however, before beginning the tuning process one should a…
    SQL Command Tool comes with APEX under SQL Workshop. It helps us to make changes on the database directly using a graphical user interface. This helps us writing any SQL/ PLSQL queries and execute it on the database and we can create any database ob…
    Video by: Steve
    Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now