.
Win-Batch / Powershell
.
What is the Windows Command Prompt?
-------------------------------------------------------------------------------------------------------
Windows Command Prompt (also known as the command line,
cmd.exe or simply cmd) is a command shell based on the MS-DOS
operating system from the 1980s that enables a user to interact
directly with the operating system. Specifically, this venerable
command shell provides an environment to run applications and
various utilities; output is displayed in the same window.
It is possible to use the cmd shell to create and edit scripts
and save them to batch files to solve automation tasks in one-system
frames; however, it was never intended for remote system administration.
************Start Batch-File***********************************************************
color CF
mode con lines=15 cols=80
echo.
::# load txtfile count
:: ####################################################
set /p mytextfile=< AutoStart-image-count.txt
echo %mytextfile%
echo %mytextfile%+1
SET /a WERT1=%mytextfile%;
SET /a WERT2=1;
SET /a SUM=0;
SET /a SUM+=%WERT1%+%WERT2%
echo %SUM%
@echo %SUM% >AutoStart-image-count.txt
:: ####################################################
::# pause
@echo %SUM%
echo.
echo ** Test Taskkill automatic Mode**
echo.
:: #pause
:: ###################################################################################################
:: #
:: # taskkill options:
:: #
:: # /f (forcefully terminate),
:: # /im (the image name of the process),
:: # /t (terminate entire process tree)
:: #
:: ###################################################################################################
echo .
:: #echo 1. Warte 1sec dann starte programm
:: #Timeout /t 2
echo .
start mspaint "AutoStart-image-count.bmp" /mov 100 200 /ren "* %~n0 *" /act ::#siz 50 50
@echo %SUM%
echo .
echo 2. Warte 1sec dann kille programm
Timeout /t 2
echo .
echo .
:: # pause
@echo %SUM%
taskkill /f /im mspaint.exe /t %vis%
echo .
echo .
:: #pause
@echo %SUM%
echo.
echo ** Done... **
echo.
:: #pause
echo 3. Warte 1sec dann restart programm
Timeout /t 1
@echo %SUM%
start AutoStart-image-count-Kill-2sec-autoRollback.bat
exit
******End Batch-File************************************************
/Downloads/Batch-PowerShell/WinBatch--Autostart+Kill+Restart.zip
What is Windows PowerShell?
------------------------------------------------------------------------------------------------------------
Windows PowerShell is a command shell and scripting language designed
for system administration tasks. It was built on top of the .NET framework,
which is a platform for software programming developed by Microsoft in 2002.
PowerShell commands, or cmdlets, help you manage your Windows infrastructure.
In addition, they enable a user to access the registry, the file system and
Windows Management Instrumentation (WMI) space on systems remotely. Moreover,
the PowerShell command shell enables you to create complex scripts
with multiple conditions.
##------------------------------------------ PowerShell-Code---------------------------------------------------------------
function Get-ScriptDirectory {
$Invocation = (Get-Variable MyInvocation -Scope 1).Value
Split-Path $Invocation.MyCommand.Path }
$installpath = Get-ScriptDirectory
##$Apppath = Get-Location
$txtbx1.Text = ($installpath)
##-------------------------------------------------------------------------
##### GUI selber
$Form = New-Object system.Windows.Forms.Form
$Form.Text = "PC-Infos"
$Form.TopMost = $true
$Form.Width = 995
$Form.Height = 500
#--------------------------------------------------------------------------------------------
##Prozesse ------------------------------------------------------------------------------
$button7.Add_Click({
$Apppath2 = $txtbx1.Text
$folder_file1 = "xx_Textfiles\Lfd_Prozesse.txt"
$Appath_folder_file1 = ($Apppath2+$folder_file1)
# Rufe Prozesse auf + speichere in txt-file
Get-Process | Out-File -FilePath ($Appath_folder_file1)
#first ##Clear List
$listView1.Items.Clear()
$listView1.Columns.Clear()
#next add to list
$listView1.Columns.Add("<Id>")
$listView1.Columns.Add("<Name>")
$listView1.Columns.Add("<CPU>")
$allProcesses = Get-Process |Select-Object Id, Name, CPU
for ($i = 0; $i -Lt $allProcesses.Count; $i++) {
$Lvi = [System.Windows.Forms.ListviewItem]::new()
$Lvi.Text = $allProcesses[$i].Id
$Lvi.SubItems.Add($allProcesses[$i].Name)
$Lvi.SubItems.Add($allProcesses[$i].CPU)
$listView1.Items.Add($Lvi)
}
$listView1.Columns[0].Width = -2
$listView1.Columns[1].Width = -2
$listView1.Columns[2].Width = -2
})
##------------------------------------------ PowerShell-Code- Ende--------------------------------------------------------------
Dokus
.
.