Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 864 Vote(s) - 3.54 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to run an application as "run as administrator" from the command prompt?

#1
I have a batch file called `test.bat`. I am calling the below instructions in the `test.bat` file:

start /min powershell.exe %sysdrive%\testScripts\testscript1.ps1

When I run this through the command prompt, my testscript is running successfully. I want to run it as administrator (as if I have created a desktop shortcut and run as administrator. It shouldn't prompt for any username or password).

I have tried adding `/elevate` and `/NOUAC` parameters in the above `test.bat`, but no luck. How do I fix this issue?

I know how to do it manually, but I want this to be executed from the command prompt.

(By [Marnix Klooster](

[To see links please register here]

)): ...without using any additional tools, like those suggested in [an answer to Super User question *How to run program from command line with elevated rights*][1].)

[1]:

[To see links please register here]

Reply

#2
See this [TechNet][1] article: [Runas command documentation][2]

From a command prompt:

C:\> runas /user:<localmachinename>\administrator cmd

Or, if you're connected to a domain:

C:\> runas /user:<DomainName>\<AdministratorAccountName> cmd

[1]:

[To see links please register here]

[2]:

[To see links please register here]

Reply

#3
Try this:

runas.exe /savecred /user:administrator "%sysdrive%\testScripts\testscript1.ps1"

It saves the password the first time and never asks again. Maybe when you change the administrator password you will be prompted again.
Reply

#4
It looks like `psexec -h` is the way to do this:

-h If the target system is Windows Vista or higher, has the process
run with the account's elevated token, if available.

Which... doesn't seem to be listed in the online documentation in *[Sysinternals - PsExec][1]*.

But it works on my machine.

[1]:

[To see links please register here]

Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through