A standard account that run one command as administator


  1. Posts : 18
    Windows 10 Pro 20H2
       #1

    A standard account that run one command as administator


    Windows 10 22H2
    Is it possible to give a standard Windows user the access to run one command as administrator without
    knowing the administrator password?
    E.G the command "wmic os get lastbootuptime"
      My Computer


  2. Posts : 16,955
    Windows 10 Home x64 Version 22H2 Build 19045.4170
       #2

    You can set this up by adding it as a Task scheduler task.
    Create Elevated App Shortcut without Admin Prompt - TenForumsTutorials
    Once you have set it up, your standard user will be able to run the task without knowing the password.


    Denis



    Welcome to TenForums.

    It's really worth making time to browse through the Tutorial index - there's a shortcut to it at the top of every page.
    - At the foot of the Tutorial index is a shortcut to download it as a spreadsheet.
    - I download a new copy each month.
    - By downloading it as a spreadsheet I can benefit from Excel's excellent filtering capabilities when I search for topics of interest.
    - Tutorials are also listed by category at Tutorials - there's also a shortcut to that at the top of every page.
    - Both tutorial lists are searchable.
    - You can also search for TenForumsTutorials in many general search engines, such as Google, by adding site:tenforums.com/tutorials after your search term. For example,
    taskbar toolbars site:tenforums.com/tutorials

    You can search TenForums using the search box in the top-right corner of all TenForums webpages or using Advanced Search - TenForums
    - You can also search TenForums threads in many general search engines, such as Google, by adding site:tenforums.com after your search term. For example,
    Search for drivers by HardwareID site:tenforums.com
    - [This is what the search box in the top-right corner of TenForums webpages does automatically]
      My Computer


  3. Posts : 16,955
    Windows 10 Home x64 Version 22H2 Build 19045.4170
       #3

    The example you chose does not need Admin permission.
    But sticking with that example for a moment, this is how you would set up such a command in Task scheduler

    Program - cmd.exe
    Arguments - /k "wmic os get lastbootuptime"
    That /k keeps the window open after the command has run.
    A standard account that run one command as administator-cmd-ts.png



    Denis
      My Computer


  4. Posts : 1,768
    Windows 10 Pro (+ Windows 10 Home VMs for testing)
       #4

    Note that WMIC has been deprecated in Windows 10/11. See this Microsoft doc - Deprecated features for Windows client - for more info.

    As a result it may be better to get used to querying WMI via PowerShell. For example, the following will do the same (and doesn't need to be run as Administrator):
    Code:
    Get-CimInstance -ClassName Win32_OperatingSystem | Select LastBootUpTime
    OR
    Code:
    (Get-CimInstance -ClassName win32_operatingsystem).lastbootuptime
    OR
    Code:
    (gcim Win32_OperatingSystem).LastBootUpTime

    A standard account that run one command as administator-get_lastbootuptime.png

    My friend's a packager so I asked him to compile it using tools at his disposal. The resulting 119k executable works fine but unfortunately a couple of VirusTotal's more - ahem - esoteric (aka unknown) scanners flagged it as malicious, presumably because it uses Windows Forms rather than the PowerShell one-liner:

    A standard account that run one command as administator-lastbootuptime-loop.gif

    Hope this helps...
    Last edited by RickC; 11 Mar 2024 at 21:19.
      My Computer


  5. Posts : 18
    Windows 10 Pro 20H2
    Thread Starter
       #5

    A standard account that run one command as administrator


    Sorry I forget to tell that the account is not used on the console or by remote-desktop but by ssh.
    On the system, beta-server, the Opensshd is installed and running.
    From an other system the command below is executed:

    ssh wmiquery@beta-server
    wmiquery@beta-server's password:
    wmiquery@beta-server>net user wmiquery | findstr Membership
    Local group Memberships "Remote Desktop Users *users

    wmiquery@beta-server>wmic os get lastbootuptime
    ERROR:
    Description = Access denied

    This should run automatically without the user interaction of clicking a desktop icon.
    ssh wmiquery@beta-server "wmic os get lastbootuptime"

    How can I give the standard user account wmiquery the access to execute by ssh the command wmic?
      My Computer


  6. Posts : 16,955
    Windows 10 Home x64 Version 22H2 Build 19045.4170
       #6

    You can't give a std user the power to run an Admin command.
    But what you can do is set it up in Task scheduler then run a shortcut to that task. That's the whole point of the tutorial I gave you a link to.
    Run the shortcut remotely in whatever way your ssh setup requires.

    The command
    Code:
    wmic os get lastbootuptime
    does not need Admin approval.
    I think that your access problem is caused by your ssh use.


    Denis
    Last edited by Try3; 12 Mar 2024 at 11:30.
      My Computer


  7. Posts : 1,768
    Windows 10 Pro (+ Windows 10 Home VMs for testing)
       #7

    As I mentioned previously, WMIC is now deprecated (and likely to be removed in a future update).

    Now the SSH transport is installed, why not use PowerShell remoting over SSH to grab the OS info that's needed?
      My Computer


  8. Posts : 16,955
    Windows 10 Home x64 Version 22H2 Build 19045.4170
       #8

    My previous post was incomplete.
    It's complete now.


    Denis
      My Computer


  9. Posts : 1,768
    Windows 10 Pro (+ Windows 10 Home VMs for testing)
       #9

    I haven't used SSH, only PowerShell remoting and stopped using WMIC a while ago.

    Shouldn't you be passing WMIC a path and username/password combo along with the actual command?

    All the examples I've seen show, for example:
    Code:
    wmic /node: <IP/servername> /domain: <domain name> /user:<username> /password:<password> os get lastbootuptime
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 18:36.
Find Us




Windows 10 Forums