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.
Related
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}"
This question already has answers here:
touch command not working, what should I use instead? [duplicate]
(2 answers)
How to create an empty log or text file with Powershell using date or timestamp?
(1 answer)
Is there a way to use the equivalent of touch in PowerShell to update timestamps of a file?
(2 answers)
Creating new file with touch command in PowerShell error message
(14 answers)
Closed 1 year ago.
Looking for a beginner friendly approach for using touch in windows
I saw this #stack and even tried googling a couple of times , but most of it seemed to create more confusion rather than solve my existing crisis.
Finally I ended up making my own function in powershell which worked similar to creating a file using touch in linux
Read with touch in Powershell using functions
Try creating the below function in powershell
function touch{ ni $args }
ni -> New-Item | if ni doesnt yeild an ans try New-Item instead
which works perfectly
Now you can try out touch as in the image below to create files
But does this mean that you would have to create a function every time you need to use?? Well, not at all my friendos
there is a better way around that. All you have to do is to add it to a powershell profile.
You open your powershell profile with the following command
notepad $profile
All you need to do now is to add the above function to this file and save it. Now close all the powershell that you have open and reopen them.This time the function gets loaded when powershell starts and it works globally which means any instance of powershell can use it now.
a better advanced implementation of touch can be found here thanks to #mklement0
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.
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"')
Yesterday I worked with some cmd files in windows, some how I could not able to open that on Today. is there any chance I can view history in command window?
Depends. If the command prompt is the same instance as yesterday you can use the up arrow key to view previous commands.
If the window has been closed commands are lost. In future you could run,
doskey /HISTORY > somecommand.log, before closing command prompt to save all commands used to a file for reference the next time you come to use it.