Page 1 of 2 12 LastLast
  1.    14 Apr 2017 #1
    Join Date : Apr 2017
    Posts : 11
    Windows 10, Debian 9

    CLI runas admin


    Code:
    net localgroup administrators
    Members
    -----------------------------
    Administrator
    user

    Code:
    runas /user:Administrator "chkdsk c:"
    <enter user, which should be administrator, pass>
    user name or password is incorrect

    Code:
    runas /user:user "chkdsk c:"
    <enter user pass>
    attempting to start chkdsk c: as user ...

    Fails to run.

    What am I missing here? Is there a way to give Administrator member its own password. It appears as though my user pass doesn't work even though it's supposedly admin. To be clear, I'm not asking how to right click. How do I elevate to admin privilege and run a program through cli?
      My ComputerSystem Spec
  2.    14 Apr 2017 #2

    This may not be a direct solution as cmd is a bit foreign to me ... however in powershell...

    Code:
    <################################################# Elevate ######################################################>
    $myWindowsID=[System.Security.Principal.WindowsIdentity]::GetCurrent()
    $myWindowsPrincipal=new-object System.Security.Principal.WindowsPrincipal($myWindowsID)
    $adminRole=[System.Security.Principal.WindowsBuiltInRole]::Administrator
    
    if (-not ($myWindowsPrincipal.IsInRole($adminRole)))
      {
        Start-Process PowerShell.exe -Verb Runas -ArgumentList $myInvocation.MyCommand.Definition
        return
       }
    <################################################################################################################>
    
    chkdsk.exe /f /r e:
    Change the drive letter to whichever - and save as something.ps1
      My ComputerSystem Spec
  3.    14 Apr 2017 #3
    Join Date : Jul 2015
    Posts : 3,694
    10 Pro

    Not sure what your question is.

    Do you mean you want to set Administrator password?
    Code:
    net user administrator Password /active:yes
    or you want to elevate privileges, for example
    Code:
    :checkPrivileges 
    NET FILE 1>NUL 2>NUL
    if '%errorlevel%' == '0' ( goto gotPrivileges 
    ) else ( powershell "saps -filepath %0 -verb runas" >nul 2>&1)
    exit /b
    windows - How can I auto-elevate my batch file, so that it requests from UAC administrator rights if required? - Stack Overflow
      My ComputerSystem Spec
  4.    14 Apr 2017 #4
    Join Date : Sep 2015
    Staffordshire
    Posts : 358
    Windows 10 Pro

    Over complicating things, just run the Command Processor as Administrator.

    Right Click Run as Administrator.

    Code:
    Microsoft Windows [Version 10.0.15063]
    (c) 2017 Microsoft Corporation. All rights reserved.
    
    C:\WINDOWS\system32>chkdsk c:
    The type of the file system is NTFS.
    Volume label is System.
    
    WARNING!  /F parameter not specified.
    Running CHKDSK in read-only mode.
    
    Stage 1: Examining basic file system structure ...
                                                                                                                                                                      327936 file records processed.                                                
    File verification completed.
                                                                                                                                                                      3606 large file records processed.
                                                                                                                                                                      0 bad file records processed.
    
    Stage 2: Examining file name linkage ...
                                                                                                                                                                      397314 index entries processed.                                               
    Index verification completed.
                                                                                                                                                                      0 unindexed files scanned.
                                                                                                                                                                      0 unindexed files recovered to lost and found.
    
    Stage 3: Examining security descriptors ...
    Security descriptor verification completed.
                                                                                                                                                                      34690 data files processed.
    CHKDSK is verifying Usn Journal...
                                                                                                                                                                      36069072 USN bytes processed.                                                 
    Usn Journal verification completed.
    
    Windows has scanned the file system and found no problems.
    No further action is required.
    
     233058303 KB total disk space.
      47762496 KB in 141521 files.
         95840 KB in 34691 indexes.
             0 KB in bad sectors.
        555091 KB in use by the system.
         65536 KB occupied by the log file.
     184644876 KB available on disk.
    
          4096 bytes in each allocation unit.
      58264575 total allocation units on disk.
      46161219 allocation units available on disk.
    
    C:\WINDOWS\system32>
      My ComputersSystem Spec
  5.    14 Apr 2017 #5
    Join Date : Jul 2015
    Posts : 3,694
    10 Pro

    Quote Originally Posted by clam1952 View Post
    Over complicating things, Right Click Run as Administrator.
    They did say in the first post:

    Quote Originally Posted by jnich View Post
    To be clear, I'm not asking how to right click.
    Perhaps you missed it.
      My ComputerSystem Spec
  6.    14 Apr 2017 #6
    Join Date : Sep 2015
    Staffordshire
    Posts : 358
    Windows 10 Pro

    Seems to be a pointless over complication just to run chkdsk......

    Maybe it doesn't work as the Computer name isn't specified? runas /user:computer name\account name chkdsk C:
      My ComputersSystem Spec
  7.    14 Apr 2017 #7
    Join Date : Apr 2017
    Posts : 11
    Windows 10, Debian 9
    Thread Starter

    Thank you lx07! I needed to set a password for Administrator member reboot and runas /user:Administrator to get it working. I'm sorry for the confusion. chkdsk was just an example.
      My ComputerSystem Spec
  8.    14 Apr 2017 #8
    Join Date : Sep 2015
    Staffordshire
    Posts : 358
    Windows 10 Pro

    OK I'm now unconfused, glad you got it sorted.
      My ComputersSystem Spec
  9.    14 Apr 2017 #9
    Join Date : Aug 2016
    S/E England
    Posts : 4,475
    10 Home x64 (1709) (10 Pro on 2nd pc)

    Quote Originally Posted by jnich View Post
    I needed to set a password for Administrator....
    Yes, runas requires the account you want to 'run as' to have a password - else you get...
    Account restrictions are preventing this user from signing in. For example: blank passwords aren't allowed...
    By default the built-in Administrator account has a blank password and is disabled. Setting a password for Administrator has a downside, it is the account used when booting to the repair environment and your emergency way in when all else fails. Forget that password and your only repair option may be a clean install.

    It would be better to leave Administrator alone, for your purposes I would create another local account (say, Admin) make that an administrator and give it a password. Then you can runas Admin rather than the built-in Administrator.
      My ComputersSystem Spec
  10.    14 Apr 2017 #10
    Join Date : Apr 2017
    Posts : 11
    Windows 10, Debian 9
    Thread Starter

    Quote Originally Posted by Bree View Post
    It would be better to leave Administrator alone, for your purposes I would create another local account (say, Admin) make that an administrator and give it a password. Then you can runas Admin rather than the built-in Administrator.
    This is where my troubles began. According to Windows, my user was the Administrator so running as that user and providing its password should have worked. I tried several times, just to be sure there wasn't a typo when entering my password. Assigning a password to Administrator and rebooting did the job. I'm not worried about forgetting a password in this environment, but I'll keep that in mind.
      My ComputerSystem Spec

 
Page 1 of 2 12 LastLast


Similar Threads
Thread Forum
No Admin Access /Cannot change existing user accounts to admin account
Hello All, I'm delighted to have found you and after a long day of trying to help myself i am now requiring your much appreciated assistance please!:cry: I'm not a techy person at all and am hoping someone can help:) Last week my husband purchased...
User Accounts and Family Safety
RunAs Taskbar
Hello! I wrote my first tool and i would like to present it here. short description: RunAs Taskbar is a free windows software to make your admin-tools easier to organize! If you run RunAs Taskbar as...
Software and Apps
runas command won't recognize administrator password
I tried the runas command to configure some software I just updated, as the directions said, but my administrator password was rejected. Then I tested the runas command on a pdf file that I know for sure is in the current directory (it can open from...
General Support
System error 5 | No admin rights | Lost admin password | can't reset
Hi Yet again, Windows is frustratingly taking up all of my time and I have tried everything google has to offer to try and fix it but it seems like no one has screwed up as much as I have on whatever forum. Let me explain the problem: I'm...
User Accounts and Family Safety
Google Earth won't install - admin privileges required (I am admin)
Frustrated with admin rights - Please help me. Just purchased new PC - HP Pavilion desktop and upgraded to Windows 10 during installation. I've downloaded Google Chrome as my default search engine with no issues. I've attempted several times to...
Software and Apps
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 05:25.
Find Us
Twitter Facebook Google+ Ten Forums iOS App Ten Forums Android App



Windows 10 Forums