8
0

Anlage des Repos

This commit is contained in:
2024-01-24 16:42:38 +01:00
commit 38d6a271c4
1785 changed files with 3051496 additions and 0 deletions

View File

@@ -0,0 +1,5 @@
:test
ECHO %computername% %date% %time% >>e:\test.txt
goto test

View File

@@ -0,0 +1,11 @@
$file = [System.io.File]::Open("E:\test.txt", 'Open', 'Read', 'ReadWrite')
#$reader = New-Object System.IO.StreamReader($file)
#$text = $reader.ReadToEnd()
#$reader.Close()
$file.Close()
Write-Host $file.CanRead
Write-Host $file.CanWrite
Write-Host $file.CanSeek
Write-Host $file.CanTimeout

View File

@@ -0,0 +1,61 @@
Set-Variable -name file -Value E:\test.pdf
function checkFileStatus1($filePath)
{
write-host (get-Date) "[ACTION][FILECHECK] Checking if" $filePath "is locked"
$fileInfo = New-Object System.IO.FileInfo $filePath
try
{
$fileStream = $fileInfo.Open( [System.IO.FileMode]::Open, [System.IO.FileAccess]::Read, [System.IO.FileShare]::Read )
write-host (get-Date) "[ACTION][FILEAVAILABLE]" $filePath
#$fileInfo.close()
#$fileInfo.dispose()
return $true
}
catch
{
write-host (get-Date) "[ACTION][FILELOCKED] $filePath is locked"
return $false
}
}
function checkFileStatus2($filePath)
{
write-host (get-Date) "[ACTION][FILECHECK] Checking if" $filePath "is locked"
$fileInfo = New-Object System.IO.FileInfo $filePath
try
{
$fileStream = $fileInfo.Open( [System.IO.FileMode]::Open, [System.IO.FileAccess]::Read, [System.IO.FileShare]::Read )
#$fileStream = $fileInfo.Open()
write-host (get-Date) "[ACTION][FILEAVAILABLE]" $filePath
$fileInfo.close()
$fileInfo.dispose()
#$fileStream = $fileInfo.Open( [System.IO.FileMode]::Open, [System.IO.FileAccess]::Read, [System.IO.FileShare]::Read )
return $true
}
catch
{
write-host (get-Date) "[ACTION][FILELOCKED] $filePath is locked"
return $false
}
}
checkFileStatus2 -filePath $file
# checkFileStatus1 -filePath $file

View File

@@ -0,0 +1,5 @@
If (-NOT ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] Administrator) -or -NOT ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] Administrator) -or -not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole("Domain Admins"))
{
Write-Warning You do not have sufficient permissions to run this script!`nPlease re-run this script as an Administrator!
Break
}

File diff suppressed because it is too large Load Diff

Binary file not shown.

View File

@@ -0,0 +1,4 @@
Dism /Online /Cleanup-Image /ScanHealth
Dism /Online /Cleanup-Image /CheckHealth
Dism /Online /Cleanup-Image /RestoreHealth
sfc /scannow

View File

@@ -0,0 +1,10 @@
$IndexService = New-Object -ComObject "WMIndexServer.WMIdxSvControl"
$IndexService.Shutdown
$IndexService.Start
$IndexService = $NULL
$ControlCenter = New-Object -ComObject "Wmcc.ControlCenter"
$ControlCenter.StartVFSService(0)
$ControlCenter.StartVFSService(1)
$ControlCenter = $NULL

View File

@@ -0,0 +1,30 @@
# Note: store in your profile for easy use
# Example use:
# $file = Select-FileDialog -Title "Select a file" -Directory "D:\scripts" -Filter "Powershell Scripts|(*.ps1)"
function Select-FileDialog
{
param([string]$Title,[string]$Directory,[string]$Filter="All Files (*.*)|*.*")
[System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") | Out-Null
$objForm = New-Object System.Windows.Forms.OpenFileDialog
$objForm.InitialDirectory = $Directory
$objForm.Filter = $Filter
$objForm.Title = $Title
$Show = $objForm.ShowDialog()
If ($Show -eq "OK")
{
Return $objForm.FileName
}
Else
{
Write-Error "Operation cancelled by user."
}
}
$file = Select-FileDialog -Title "Select a file" -Directory "D:\scripts" -Filter "Powershell Scripts (*.ps1)|*.ps1"
#multiple file category arguments should not include extra space:
#-Filter “Text files (*.txt) | *.txt | All files (*.*) | *.*”
#does not work — only show *.* filter.
#-Filter “Text files (*.txt)|*.txt|All files (*.*)|*.*”
#works.

View File

@@ -0,0 +1,162 @@
#Generated Form Function
function GenerateForm {
########################################################################
# Code Generated By: SAPIEN Technologies PrimalForms v1.0.1.0
# Generated On: 25/01/2009 14:50
# Generated By: administrator
########################################################################
#region Import the Assembles
[reflection.assembly]::loadwithpartialname(System.Windows.Forms) | Out-Null
[reflection.assembly]::loadwithpartialname(System.Drawing) | Out-Null
#endregion
#region Generated Form Objects
$form1 = New-Object System.Windows.Forms.Form
$DisplayFile_Window = New-Object System.Windows.Forms.RichTextBox
$SelectFile_Window = New-Object System.Windows.Forms.RichTextBox
$SelectFile = New-Object System.Windows.Forms.Button
$groupBox1 = New-Object System.Windows.Forms.GroupBox
$Displayfile = New-Object System.Windows.Forms.Button
$openFileDialog1 = New-Object System.Windows.Forms.OpenFileDialog
#endregion Generated Form Objects
#———————————————-
#Generated Event Script Blocks
#———————————————-
#Provide Custom Code for events specified in PrimalForms.
$EnteredText=
{
$ifile = $SelectFile_Window.Text
}
$Displayfile_OnClick=
{
If(!$ifile -eq $False)
{
$iFileGC = Get-content $ifile
$iFileContents = [string]::join([environment]::NewLine,$iFileGC)
$DisplayFile_Window.Text = $iFileContents
}
Else {$DisplayFile_Window.Text = No file selected}
}
$SelectFile_OnClick=
{
$openFileDialog1.ShowDialog()
$ifile = $openFileDialog1.FileName
$SelectFile_Window.Text = $ifile
}
#———————————————-
#region Generated Form Code
$form1.Text = My 1st Primal Form
$form1.Name = form1
$form1.DataBindings.DefaultDataSourceUpdateMode = 0
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 299
$System_Drawing_Size.Width = 436
$form1.ClientSize = $System_Drawing_Size
$DisplayFile_Window.WordWrap = $False
$DisplayFile_Window.Name = DisplayFile_Window
$DisplayFile_Window.Text =
$DisplayFile_Window.DataBindings.DefaultDataSourceUpdateMode = 0
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 10
$System_Drawing_Point.Y = 64
$DisplayFile_Window.Location = $System_Drawing_Point
$DisplayFile_Window.ReadOnly = $True
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 223
$System_Drawing_Size.Width = 409
$DisplayFile_Window.Size = $System_Drawing_Size
$DisplayFile_Window.TabIndex = 3
$form1.Controls.Add($DisplayFile_Window)
$SelectFile_Window.Multiline = $False
$SelectFile_Window.WordWrap = $False
$SelectFile_Window.Name = SelectFile_Window
$SelectFile_Window.Text =
$SelectFile_Window.DataBindings.DefaultDataSourceUpdateMode = 0
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 12
$System_Drawing_Point.Y = 35
$SelectFile_Window.Location = $System_Drawing_Point
$SelectFile_Window.EnableAutoDragDrop = $True
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 23
$System_Drawing_Size.Width = 293
$SelectFile_Window.Size = $System_Drawing_Size
$SelectFile_Window.TabIndex = 1
$SelectFile_Window.add_TextChanged($EnteredText)
$form1.Controls.Add($SelectFile_Window)
$SelectFile.TabIndex = 0
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 23
$System_Drawing_Size.Width = 27
$SelectFile.Size = $System_Drawing_Size
$SelectFile.Name = SelectFile
$SelectFile.UseVisualStyleBackColor = $True
$SelectFile.Text =
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 311
$System_Drawing_Point.Y = 34
$SelectFile.Location = $System_Drawing_Point
$SelectFile.DataBindings.DefaultDataSourceUpdateMode = 0
$SelectFile.add_Click($SelectFile_OnClick)
$form1.Controls.Add($SelectFile)
$groupBox1.Name = groupBox1
$groupBox1.Text = Select file to view
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 284
$System_Drawing_Size.Width = 426
$groupBox1.Size = $System_Drawing_Size
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 3
$System_Drawing_Point.Y = 12
$groupBox1.Location = $System_Drawing_Point
$groupBox1.TabStop = $False
$groupBox1.DataBindings.DefaultDataSourceUpdateMode = 0
$groupBox1.TabIndex = 5
$form1.Controls.Add($groupBox1)
$Displayfile.TabIndex = 0
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 23
$System_Drawing_Size.Width = 75
$Displayfile.Size = $System_Drawing_Size
$Displayfile.Name = Displayfile
$Displayfile.UseVisualStyleBackColor = $True
$Displayfile.Text = Display file
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 341
$System_Drawing_Point.Y = 22
$Displayfile.Location = $System_Drawing_Point
$Displayfile.DataBindings.DefaultDataSourceUpdateMode = 0
$Displayfile.add_Click($Displayfile_OnClick)
$groupBox1.Controls.Add($Displayfile)
$openFileDialog1.FileName = openFileDialog1
#endregion Generated Form Code
#Show the Form
$form1.ShowDialog()| Out-Null
} #End Function
#Call the Function
GenerateForm

View File

@@ -0,0 +1,4 @@
function Start-RDP ($computername)
{
Start-Process "$env:windir\system32\mstsc.exe" -ArgumentList "/v:$computername"
}

File diff suppressed because it is too large Load Diff

Binary file not shown.

View File

@@ -0,0 +1,28 @@
$REMOTE='https://webdav.example.com/';
$REMOTEFOLDER = 'folder';
$USERNAME = '';
$PASSWORD = '';
# Define custom auth header
$authH = @{Authorization='Basic {0}' -f [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("${USERNAME}:${PASSWORD}")))};
# Define custom WebRequest function to allow WebDav-Methods PROPFIND and MKCOL
# With PowerShell 6 use "Invoke-RestMethod -CustomMethod" instead
function Invoke-CustomRequest($Method, $Url){
$req = [net.webrequest]::create($Url);
$req.Headers['Authorization'] = $authH.Authorization;
$req.Headers['Depth'] = '1';
$req.Method = $Method;
$reader = [System.IO.StreamReader]::new($req.GetResponse().GetResponseStream());
$props = $reader.ReadToEnd();
return $props;
}
# Clean up all files on remote: List all files on root (PROPFIND), XPath to find hrefs then call DELETE for each
Invoke-CustomRequest -Method 'PROPFIND' -Url $REMOTE/$REMOTEFOLDER/ | Select-Xml -XPath "//*[local-name()='href']" | % { $_.Node.'#text' } | % { Invoke-CustomRequest -Method "DELETE" -Url "$REMOTE/$_" }
# Create all directories: find all directories with relative paths and call MKCOL to create on remote
Get-ChildItem -Directory -Recurse | % {$_.FullName | Resolve-Path -Relative} | % { Invoke-CustomRequest -Method "MKCOL" -Url "{0}/{1}" -f $REMOTE,$_ -Replace '\\','/' }
# Copy all files: find all files with relative paths then call PUT
Get-ChildItem -File -Recurse | % {$_.FullName | Resolve-Path -Relative} | % { Invoke-WebRequest -Method "PUT" -Headers $authH -Infile $_ "{0}/{1}" -f $REMOTE,$_ -Replace '\\','/' }

View File

@@ -0,0 +1,23 @@
ArchiveFolder "sub\foo.zip", "..\baz"
Sub ArchiveFolder (zipFile, sFolder)
With CreateObject("Scripting.FileSystemObject")
zipFile = .GetAbsolutePathName(zipFile)
sFolder = .GetAbsolutePathName(sFolder)
With .CreateTextFile(zipFile, True)
.Write Chr(80) & Chr(75) & Chr(5) & Chr(6) & String(18, chr(0))
End With
End With
With CreateObject("Shell.Application")
.NameSpace(zipFile).CopyHere .NameSpace(sFolder).Items
Do Until .NameSpace(zipFile).Items.Count = _
.NameSpace(sFolder).Items.Count
WScript.Sleep 1000
Loop
End With
End Sub

View File

@@ -0,0 +1,106 @@
'*****************************************************
'************ Autor: Boris Toll ************
'P: SCRDEC //////
'12:2004 //////
'File: toVBS.vbs //////
'*****************************************************
' # Description:: Drag & drop the File to decode over the Script
Dim VBEFile, fso
If WScript.Arguments.Count = 0 Then
WScript.Echo "Kein Parameter angegeben"
Else
On Error Resume Next
For each Argument in WScript.Arguments
VBEFile = VBEFile & Argument & " "
Next
Set fso = WScript.CreateObject("Scripting.FileSystemObject")
If fso.FileExists(VBEFile) Then
Dim vbe,Conten
Set vbe = fso.OpenTextFile(VBEFile, 1)
Conten=vbe.readAll
CHKerr()
vbe.close
Set vbe=Nothing
Const TagInit = "#@~^" '#@~^awQAAA==
Const TagFin = "==^#~@" '& chr(0)
Dim DebCode, FCode
Do
FCode=0
DebCode = Instr(Conten,TagInit)
If DebCode>0 Then
If (Instr(DebCode,Conten,"==")-DebCode)=10 Then 'If "==" follows the tag
FCode=Instr(DebCode,Conten,TagFin)
If FCode>0 Then
Conten=Left(Conten,DebCode-1) & _
Decode(Mid(Conten,DebCode+12,FCode-DebCode-12-6)) & _
Mid(Conten,FCode+6)
End If
End If
End If
Loop Until FCode=0
des = mid(VBEFile,1,InstrRev(VBEFile,".",-1)) & "vbs"
Set vbs = fso.OpenTextFile(des, 2, True)
vbs.Write Conten
vbs.close
End If
Set fso=Nothing
end if
Function Decode(Csrc)
Dim se,i,c,j,index,CsrcTemp
Dim tDecode(127)
Const Combinaison = "1231232332321323132311233213233211323231311231321323112331123132"
Set se=WSCript.CreateObject("Scripting.Encoder")
For i=9 to 127
tDecode(i)="JLA"
Next
For i=9 to 127
CsrcTemp=Mid(se.EncodeScriptFile(".vbs",string(3,i),0,""),13,3)
For j=1 to 3
c=Asc(Mid(CsrcTemp,j,1))
tDecode(c)=Left(tDecode(c),j-1) & chr(i) & Mid(tDecode(c),j+1)
Next
Next
tDecode(42)=Left(tDecode(42),1) & ")" & Right(tDecode(42),1)
Set se=Nothing
Csrc=Replace(Replace(Csrc,"@&",chr(10)),"@#",chr(13))
Csrc=Replace(Replace(Csrc,"@*",">"),"@!","<")
Csrc=Replace(Csrc,"@$","@")
index=-1
For i=1 to Len(Csrc)
c=asc(Mid(Csrc,i,1))
If c<128 Then index=index+1
If (c=9) or ((c>31) and (c<128)) Then
If (c<>60) and (c<>62) and (c<>64) Then
Csrc=Left(Csrc,i-1) & Mid(tDecode(c),Mid(Combinaison,(index mod 64)+1,1),1) & Mid(Csrc,i+1)
End If
End If
Next
Decode=Csrc
End Function
Private Function CHKerr()
if err.number <> 0 then
if err.number = 62 then
WScript.echo "Fehlercode: " & err.number & vbcrlf & err.description & vbcrlf & "Leere Dateien können nicht umgewandelt werden"
err.clear
else
WScript.echo "Fehlercode: " & err.number & vbcrlf & err.description
err.clear
end if
end if
End Function

View File

@@ -0,0 +1,6 @@
Dim vprglist : Set vprglist = CreateObject("System.Collections.ArrayList")
...
If vprogram.LastRunTime = "" Then
vprglist.Add vprogram.FullName
i = i + 1
End If

View File

@@ -0,0 +1,52 @@
'*****************************************************
'************ Autor: Boris Toll ************
'P: SCRENC //////
'12:2004 //////
'File: toVBE.vbs //////
'*****************************************************
' # Description:: Drag & drop the File to encode over the Script
If WScript.Arguments.Count = 0 Then
WScript.Echo "Kein Parameter angegeben"
Else
On Error Resume Next
Set fso = CreateObject("Scripting.FileSystemObject")
For each Argument in WScript.Arguments
skript = skript & Argument & " "
Next
Set Codex = fso.OpenTextFile(skript)
code = Codex.ReadAll
CHKerr()
Codex.close
Set SEncod = CreateObject("Scripting.Encoder")
newcode = SEncod.EncodeScriptFile(".vbs", code, 0, "")
script = fso.GetBaseName(skript)
path = fso.GetParentFolderName(skript)
newname = script & ".vbe"
newpathname = fso.BuildPath(path, newname)
Set newfile = fso.CreateTextFile(newpathname, true)
newfile.Write newcode
newfile.close
end if
Private Function CHKerr()
if err.number <> 0 then
if err.number = 62 then
WScript.echo "Fehlercode: " & err.number & vbcrlf & err.description & vbcrlf & "Leere Dateien können nicht umgewandelt werden"
err.clear
else
WScript.echo "Fehlercode: " & err.number & vbcrlf & err.description
err.clear
end if
end if
End Function

View File

@@ -0,0 +1,8 @@
Set GetRecentFile = Nothing
For Each objFile In objFolder.Files
If GetRecentFile is Nothing then
Set GetRecentFile = objFile
ElseIf objFile.DateLastModified > GetRecentFile.DateLastModified then
Set GetRecentFile = objFile
End If
Next

View File

@@ -0,0 +1,19 @@
Sub Include(file)
Dim fso, f
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile(file & ".vbs", 1)
str = f.ReadAll
f.Close
ExecuteGlobal str
End Sub
' Now call Include and then call Doit
Include "TestModule"
Doit

View File

@@ -0,0 +1,3 @@
Sub Doit
MsgBox "Hello"
End Sub

View File

@@ -0,0 +1,40 @@
'TITLE: FORMEL-RÜCKSTAND
'Rückstand aus altem Lieferschein?
'Stand: MK // 14.04.2022
On Error resume next
WinLineCurrentMandatorNr = Cstr(CWLStart.CurrentCompany.Nr)
WinLineCurrentYear = cint(CWLStart.CurrentCompany.CompanyYear)
Auftragsnummer = Value (25,44)
Lieferscheinnummer = Value (25,45)
Projektnummer = Value (25,136)
SQLQuery_PredecessorDeliveryNote = "" &_
"SELECT TOP 1 [C045] from [v250] (NOLOCK) " & vbCrlf & _
"WHERE [c025] <> 'L' " & vbCrlf & _
" and [c044] = '" & Auftragsnummer & "' " & vbCrlf & _
" and [c045] IS NOT NULL " & vbCrlf & _
" and [c045] <> '" & Lieferscheinnummer & "' " & vbCrlf & _
" and [c100] > 0 " & vbCrlf & _
" and [c136] = '" & Projektnummer & "' " & vbCrlf & _
" and [c137] = 2 " & vbCrlf & _
" and [c139] in (3,-3) " & vbCrlf & _
" and [mesocomp] = '" & WinLineCurrentMandatorNr & "' " & vbCrlf & _
" and [mesoyear] in (" & WinLineCurrentYear & ",(" & WinLineCurrentYear & "-12)) " & vbCrlf & _
"Order by [C022] asc; "
Set Conn = CWLStart.CurrentCompany.Connection
If (Len(Auftragsnummer) > 0) and (Len(Projektnummer) > 0) Then
Set SQLQueryResult_PredecessorDeliveryNote = Conn.Select(SQLQuery_PredecessorDeliveryNote)
If (SQLQueryResult_PredecessorDeliveryNote.RowCount) > 0 Then
ResultValue = "Rückstand aus Lieferschein: " & SQLQueryResult_PredecessorDeliveryNote.value("c045")
Else
ResultValue = ""
End if
Else
ResultValue = ""
End If

View File

@@ -0,0 +1,6 @@
Set objFSO=CreateObject("Scripting.FileSystemObject")
outFile="E:\Text.txt"
Set objFile = objFSO.CreateTextFile(outFile,True)
objFile.Write "medacom test string" & vbCrLf
objFile.Close

View File

@@ -0,0 +1,24 @@
Set objDictionary = CreateObject("Scripting.Dictionary")
arrItems = Array("a","b","b","c","c","c","d","e","e","e")
For Each strItem in arrItems
If Not objDictionary.Exists(strItem) Then
objDictionary.Add strItem, strItem
End If
Next
intItems = objDictionary.Count - 1
ReDim arrItems(intItems)
i = 0
For Each strKey in objDictionary.Keys
arrItems(i) = strKey
i = i + 1
Next
For Each strItem in arrItems
Wscript.Echo strItem
Next