Run file with admin through cmd [duplicate] - windows

This question already has answers here:
How to run 'sudo' command in windows [duplicate]
(17 answers)
Running a command as Administrator using PowerShell?
(28 answers)
How to open an elevated cmd using command line for Windows?
(30 answers)
Closed 7 months ago.
I need to run a file as administrator. When opening a file in cmd you write "start applicationhere" and it starts, but it starts without administrator. Is it possible that I run a file through cmd with administrator? Example "withadminpower start applicationhere".

cmd.exe itself cannot UAC elevate, you need to call Powershell:
powershell -Command "&{Start-Process -Verb RunAs winver.exe}"

Related

How to hide PowerShell startup advertisement? [duplicate]

This question already has answers here:
How to remove powershell ads and update checks in the Windows Terminal?
(2 answers)
Closed 7 months ago.
When I using Ubuntu,the first line of terminal is prompt and my command.
But on Windows PowerShell,it shows an advertisement firstly each time I run terminal.
Is there any method to hide it?
I try to add cls command to profile but the effect is quite bad(the screen flicks).
Add a call to the Clear-Host cmdlet as the last statement in your $PROFILE script:
'Clear-Host' |Add-Content $PROFILE -Force
The profile script will run every time you launch PowerShell, and Clear-Host will then scroll the prompt to the top of the screen buffer, giving you a layout identical to the ubuntu terminal.

How to run cmd as admin? But in command line [duplicate]

This question already has answers here:
Opening up Windows Terminal with elevated privileges, from within Windows Terminal
(13 answers)
Closed 2 years ago.
I'm looking for a way to be able to open cmd as admin with code. So like linux. We just execute "sudo su" command for be admin. But ı want this for windows. So ı want execute a command in cmd like "sudo su" and be admin. How can ı do this?
You should run:
runas /user:administrator cmd
then enter the administrator password.
runas /savecred /user:myadminaccount "myprocess.exe"
if ypu mean open an administrative commandline you havd a few options:
1: Right click run as adminiatrator on the cmd shortcut or executable
2: Right click, open properties of shortcut or exe, click "run with administrator priviledges" and click okay, now when you open it it launches as administrator
3: launch cmd from a powershell session specifying to run cmd as administrator
4: from wirhin cmd, run powershell directly, with the appropriate switches to run it as administrator.
-- Not at my computer and dont remember the powershell commands needed to do this offhand.
So I will fill that in later if this is the needed solution, or anothwr member may do so ofc. either by editing this or answering seperately.
just let us know if that was the real need you wanted.

How do I make it so that double-clicking a ps1 file opens powershell? [duplicate]

This question already has answers here:
Is there a way to make a PowerShell script work by double clicking a .ps1 file?
(22 answers)
Closed 2 years ago.
I want to be able to double click a powershell script and it to open in powershell instead of notepad. Can I do that?
To run powershell scripts from the file you right-click the script then click run with powershell, can I make it so that double-clicking the script defaults to opening the script in powershell?
Use
ftype Microsoft.PowerShellScript.1="C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" "%1"
In administrator cmd. Ftype changes double-click behavior of certain filetypes specified by the assoc cmd command.

How can I download a file from the Internet via Command Prompt? [duplicate]

This question already has answers here:
How can I download a file with batch file without using any external tools?
(2 answers)
Closed 6 years ago.
As mentioned in the title I need a command line that allows me to download a file in the background without installing any tool just cmd I found this one but it doesn't work in the background and Need a confirmation
C:\windows\explorer.exe https://www.website.com/file.zip
so how to make the magic happen? and is there another command that i need to add it to the above line like a confirmation !?
CMD doesn't have a built-in download command. You can download a utility like wget, and get the file with
C:\> wget https://www.website.com/file.zip
PowerShell, which is built into every version of Windows 7 and above, does have a built-in command for downloading in Invoke-Webrequest
PS> Invoke-WebRequest -Uri 'https://www.website.com/file.zip' -OutFile 'c:\temp\file.zip'
You can invoke this in one line from CMD by using the following PowerShell.exe command line.
powershell -c "Invoke-WebRequest -Uri 'https://www.website.com/file.zip' -OutFile 'c:\temp\file.zip'"

OS.SYSTEM Hide pop up cmd [duplicate]

This question already has answers here:
How do I hide the console when I use os.system() or subprocess.call()?
(5 answers)
Closed 5 years ago.
If I run Hello.pyw
import os
os.system('start hello.exe')
I get a very popup cmd.
How do I run this script without cmd popup.
Lose start from your command.
According to start MSDN page or start /?:
Starts a separate window to run a specified program or command.
os.system('hello.exe')
Or if instead of hello.exe you need to run a bat/cmd file, use cmd /c (cmd /? for full cmd options):
os.system('cmd /c "hello.bat"')

Resources