Is there a windows shell tool can keep history? [closed] - shell

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 9 years ago.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Improve this question
I use windows 7 64bit. I found both cmd.exe and powershell cannot keep history. It means it lost my command history when I quit the shell.
Is there a tools can help cmd.exe or powershell to remember the history? I try to use console 2. Console 2 is tiny and has a tab interface. But console 2 can't remember the history too. Maybe there is another front end can do this.

The answer below is from Keith Hill (PowerShell Microsoft MVP) in his answer to the question powershell history: how do you prevent duplicate commands:
BTW if you want to automatically save this on exit you can do this on 2.0 like so:
Register-EngineEvent PowerShell.Exiting {
Get-History -Count 32767 | Group CommandLine |
Foreach {$_.Group[0]} | Export-CliXml "$home\pshist.xml" } -SupportEvent
Then to restore upon load all you need is:
Import-CliXml "$home\pshist.xml" | Add-History

There's an excellent post on the Windows PowerShell Blog that provides a way of preserving command history across sessions:
http://blogs.msdn.com/b/powershell/archive/2006/07/01/perserving-command-history-across-sessions.aspx
The pertinent commands for exporting and importing the command history are Get-History and Add-History. Add the following to your PowerShell profile:
Register-EngineEvent PowerShell.Exiting {
Get-History | Export-Csv $HOME\pshist.csv
} | Out-Null
if (Test-Path $Home\pshist.csv) {
Import-Csv $HOME\pshist.csv | Add-History
}
This will preserve the history in such a way that you can still inspect the history for start and end times, and calculate the duration of each.
A warning though: The above script will only remember the history of the most recently exited PowerShell window. If you work with multiple shell sessions at the same time, then the history of all but one of them will be lost.

Related

PowerShell Windows script to rename selected files launched with a hotkey [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed last year.
Improve this question
I'm trying to adapt this script that is called through a contextual menu:
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\AllFilesystemObjects\shell\RenameWithTimestamp]
#="Rename: Add Date Modified"
[HKEY_CLASSES_ROOT\AllFilesystemObjects\shell\RenameWithTimestamp\Command]
#="PowerShell.exe -WindowStyle Hidden -Command \"( Get-Item -LiteralPath '%1' ) | %%{ Rename-Item -LiteralPath $_.FullName -NewName ( '{0:yyyyMMdd_HHmmss} {1} {2}' -f $_.LastWriteTime,$_.BaseName, $_.Extension ) }\""
I would like to be able to execute this PowerShell script without right click contextual menu, only select the files and then launch the script that rename the selected files. Any idea?

Viewing the contents of a deleted shell script that is still running [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 2 years ago.
Improve this question
Another post offered a solution for a self deleting shell script rm -- "$0"
If this line is inserted at the top of the script then the script will delete itself as soon as it starts running.
Is it possible to get the contents of the deleted script while it continues to run (meaning a process is still showing up via ps -eaf | grep scriptname)?
This way you can restore the script to its original position. $pid contains the PID of your script, e.g. 12345.
pid=12345
cat /proc/$pid/fd/255 > "$(readlink /proc/$pid/fd/255 | sed 's/ (deleted)$//')"

Remove Components from Windows 10 like ntlite does [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 4 years ago.
Improve this question
I only started to program c++ half a year ago, and would be so happy if you could just help me out by giving me a point to start with.
I want to understand how ntlite removes drivers from the iso.
I want to know what do I need to learn/know/read about to program
a tool myself that removes stuff like that. For example the w-lan drivers
or Cortana.
By researching I came across:
the windows registry
powershell
...and that's it. Nothing like "learn the powershell to tweak your system tutorial" and before I start reading a book about these topics, I wanted to know if it is the right way to achieve my goal?
I am sorry if my question is unwelcome or stupid. I just want to learn about
these things and can't find the right way to start.
Thanks in advance!
If you want to remove elements from Windows, you can do that using the Add-WindowsOptionalFeature and Remove-WindowsOptionalFeature PowerShell Cmdlets.
Let's say you wanted to remove the new Calc.exe and return to the old, correct Calc.exe app.
You can do that in your running Windows Instance using this command (when running PowerShell as an Administrator)
Disable-WindowsOptionalFeature -Online -FeatureName "Calc" -PackageName
"Microsoft.Windows.Calc.Demo~6595b6144ccf1df~x86~en~1.0.0.0"
If you wanted to remove it from a Windows Image instead, first you have to mount the Windows image by mounting install.wim from the disc using the Mount-WindowsImage cmdlet, like this.
Mount-WindowsImage -ImagePath "c:\imagestore\install.vhd" -Index 1 -Path "c:\offline"
This would mount the image to your c:\Offline folder. The folder needs to exist first, BTW.
Next, to disable the feature in the Windows Image.
Disable-WindowsOptionalFeature -Path "c:\offline" -FeatureName "Calc" -PackageName
"Microsoft.Windows.Calc.Demo~6595b6144ccf1df~x86~en~1.0.0.0" -Remove
When that's done, you save the changes using:
Dismount-WindowsImage -Path "c:\offline" -Save
NtLite and these PowerShell tools all use the Deployment Image Servicing Manager tool, DISM, and its C# libraries to actually enact the changes. If you want to know more, read this and this.

how to net stop server from a batch file when there are open connections? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
I've found a few scripts here and elsewhere to start/stop windows services, locally or remotely, using net, sc, psservices, but none covers the case of force stopping the server service when the system replies that there are open connections.
Anyone has a solution for that?
This batch script runs the powershell Stop-Service cmdlet and uses the -force parameter. It will stop the service regardless of open connections, tested on Terminal Services with open RDP session.
#ECHO OFF
start /b /wait powershell.exe -command "Stop-Service -name TermService -force;$STATUS = (Get-Service termservice).status;Write-Host `"Termservice is $STATUS`""
PAUSE

Any tool that can make program runs under different user in Windows? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 8 years ago.
Improve this question
Say I want my program runs under predefined SYSTEM account, instead of the current logon user, do you know any tool that can help?
ShellRunas v1.01
You can download it for free here.
http://technet.microsoft.com/en-us/sysinternals/cc300361.aspx
ShellRunas v.1.0 is a new Sysinternals tools by Mark Russinowich. It enables you to run a program with different credentials from Windows Explorer.
Usage:
shellrunas [/reg | [/quietreg ] | /regnetonly [/quiet] | unreg | [/netonly] <program> <arguments>
Here's a post explaining running a CMD prompt as SYSTEM account, using the psexec tool. Like the ShellRunAs tool, psexec was also Mark Russinovich; unlike ShellRunAs, psexec can execute command on remote systems & has more program options.
"run as" command might also work, but I haven't verified it for use with the SYSTEM account. Here's the info for "run as" in 2000 and XP and again for Vista, 7, & 8.

Resources