How to use RunAs without password prompt?

Page 1 of 2 12 LastLast

  1. Posts : 69
    Windows 10 Pro x64
       #1

    How to use RunAs without password prompt?


    Hi!

    I tried to use RunAs to start and program as admin.
    After entering this command:

    RunAs.exe /user:Administrator "regedit.exe"

    it shows prompt to enter password.

    Is possible to override password prompt by any way?
    Or enter password in command?

    Thank you for help.
    Miro
      My Computer


  2. Posts : 1,680
    X
       #2

    Are you logged into an account with admin privilege?
      My Computer


  3. Posts : 69
    Windows 10 Pro x64
    Thread Starter
       #3

    I have only one account and it's admin acccount.

    Miro
      My Computer


  4. Posts : 4,224
    Windows 10
       #4

    You are telling the runas program to use the built-in account named "Administrator." If you're logged into an administrator account you can simply launch an administrative PowerShell or Cmd.exe session and run the regedit program without invoking the other account. Thus, for example because I don't have the built-in account enabled at present (it's disabled by default), here's what happened when I ran your command, followed by simply typing regedit.exe (which launched the registry editor with admin privileges just fine):
    How to use RunAs without password prompt?-image.png
    HTH,
    --Ed--

    PS: you can check the status of the built-in administrator account by typing "net user administrator" at an administrative command prompt or in an administrative PowerShell session. Here's how I know for sure that the administrator account is not active on my PC:
    How to use RunAs without password prompt?-biadmin-info.jpg
      My Computers


  5. Posts : 68,997
    64-bit Windows 11 Pro for Workstations
       #5

    Hello Miro,

    If you like, you could create an elevated shortcut to "Run as administrator" without getting a UAC prompt.

    Create Elevated Shortcut without UAC prompt in Windows 10 | Windows 10 Tutorials
      My Computers


  6. Posts : 69
    Windows 10 Pro x64
    Thread Starter
       #6

    I have UAC turned off.
    What a purpose is to run any program as admin:
    I want to add to context menu of desktop, drive and folder run as admin 2 cmd alternatives to access selected destination as admin.
    Instead:
    Console.exe "%1"
    use command which starts it as admin.
    Of course edited by Registry Editor.

    Miro
      My Computer


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

    EdTittel said:
    PS: you can check the status of the built-in administrator account by typing "net user administrator" at an administrative command prompt or in an administrative PowerShell session.

    As the SID for the local Administrator is a constant, I use the following PowerShell cmdlet (as part of a diagnostic script that appends to a text file):
    Code:
    Get-WmiObject Win32_useraccount | Where-Object {$_.SID -like '*-500'} | Select Name, Disabled
    How to use RunAs without password prompt?-admin-enabled.jpg
    (Of course, you can always omit Name from the Select statement to make it even shorter.)

    Hope this helps...
      My Computer


  8. Posts : 69
    Windows 10 Pro x64
    Thread Starter
       #8

    I don't know if it helps, really I meant that it is easier to start program as admin from command line...

    Miro
      My Computer


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

    1. Create a shortcut to the Registry Editor then right-click on the shortcut and choose Properties.
    2. Click on the Advanced button (a) then put a tick in the Run as administrator checkbox (b).
    3. Click on each of the OK buttons to dismiss the dialogs.

    How to use RunAs without password prompt?-regedit-admin.jpg

    Alternatively, you can also use tools like AutoHotkey to run programs elevated. For example, the following also runs the Registry Editor as Administrator:
    Code:
    ; Prompt to 'Run as Admin', i.e. elevated
    If Not A_IsAdmin
    {
       Run *RunAs "%A_ScriptFullPath%"  ; Requires v1.0.92.01+
       ExitApp
    }
    
    Run %windir%\regedit.exe
    Exit
    Hope this helps...
      My Computer


  10. Posts : 69
    Windows 10 Pro x64
    Thread Starter
       #10

    Even I'm using and creating AHK scripts...
    I think we lost main problem - please forgive me that's not at beginning of thread.

    So, why and what I need?

    I need to add to context menu of drive, desktop, folder opening two cmd.exe alternatives (Take Command and Console) as admin.
    I have in context menu of these destinations cmd.exe yet - but it's downloaded from web, not my work.

    For making it more clear here's context menu of folder background (empty place of File Explorer opened folder):
    key:
    Code:
    Computer\HKEY_CLASSES_ROOT\Directory\Background\shell\runas\command
    value:
    Code:
    cmd.exe /s /k pushd "%V"⧹
    Other destinations are similar or the same.
    Miro
      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 15:23.
Find Us




Windows 10 Forums