The complete folder structure has been changed or updated
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
ECHO "TEST"
|
||||
pause
|
||||
@@ -0,0 +1,2 @@
|
||||
Write-Host "Test"
|
||||
pause
|
||||
@@ -0,0 +1 @@
|
||||
msgbox "TEST"
|
||||
225
current/DD-Core/Start-ExeOrScriptFile/Start-ExeOrScriptFile.cmd
Normal file
225
current/DD-Core/Start-ExeOrScriptFile/Start-ExeOrScriptFile.cmd
Normal file
@@ -0,0 +1,225 @@
|
||||
@ECHO OFF
|
||||
TITLE DIGITAL DATA - %~n0
|
||||
ECHO -
|
||||
ECHO Windows Command Line Script
|
||||
ECHO CMD Version %CMDEXTVERSION% active!
|
||||
ECHO -
|
||||
ECHO Digital Data
|
||||
ECHO Ludwig-Rinn-Strasse 16
|
||||
ECHO 35452 Heuchelheim
|
||||
ECHO Tel.: 0641 / 202360
|
||||
ECHO E-Mail: info@didalog.de
|
||||
ECHO -
|
||||
ECHO Version Number: 1.0.0.0
|
||||
ECHO Version Date: 03.06.2018
|
||||
|
||||
pushd "%~dp0"
|
||||
setlocal
|
||||
|
||||
REM --------------------------------------------------------------
|
||||
REM ----------------------- set variables ------------------------
|
||||
REM --------------------------------------------------------------
|
||||
|
||||
SET ScriptName=%~n0
|
||||
REM Automatic defined Variable, do not change!
|
||||
REM Write WITHOUT double Quotes("")!
|
||||
|
||||
SET ScriptPath=%~dp0
|
||||
REM Automatic defined Variable, do not change!
|
||||
REM Write WITHOUT double Quotes("")!
|
||||
|
||||
SET SearchPath=%cd%\
|
||||
REM Automatic defined Variable, maybe change, if you want to search in designated folder - dont forget the "\" in the end!
|
||||
REM Write WITHOUT double Quotes("")!
|
||||
|
||||
SET SearchFileFilter="*-Example.cmd,*-Example.vbs,*-Example.ps1,*-Example.exe"
|
||||
REM Set File extension *.exe, *.ps1, *.vbs or *.cmd. Or set whole Filename like test.ps1. Wildcard is also possible: test*.ps1. Also a comma seperated list is possible like *.ps1, *.vbs.
|
||||
REM Write WITHOUT double Quotes(""), for a single value! Write WITH double Quotes(""), for comma seperated values.
|
||||
|
||||
SET Counter=0
|
||||
REM Predefined Variable, do not change!
|
||||
REM Write WITHOUT double Quotes("")!
|
||||
|
||||
SET PowerShellCMD=powershell.exe -ExecutionPolicy Bypass -WindowStyle Hidden -File
|
||||
REM Predefined Variable, do not change!
|
||||
REM Write WITHOUT double Quotes("")!
|
||||
|
||||
SET PowerShellRuntimeScript="%ScriptPath%\%ScriptName%_PowerShellRuntimeScript.ps1"
|
||||
REM Automatic defined Variable, do not change!
|
||||
REM Write WITH double Quotes("")!
|
||||
|
||||
SET PowerShellWaitForExit=True
|
||||
REM Set to "True" if found EXE or Scripts Files should be processed one after another. Otherwise set to "False".
|
||||
REM Write WITHOUT double Quotes("")!
|
||||
|
||||
SET RunAsUserName=
|
||||
REM Set an Username, if you want the EXE or Scripts Files run in an other context, like: "Administrator". But maybe: "domain\Administrator".
|
||||
REM Write WITHOUT double Quotes("")!
|
||||
|
||||
SET RunAsUserPassword=
|
||||
REM Set Password if you defined the RunAsUserName Variable.
|
||||
REM Write WITHOUT double Quotes("")!
|
||||
|
||||
REM --------------------------------------------------------------
|
||||
GOTO mainpart
|
||||
REM --------------------------------------------------------------
|
||||
REM ------------------------- subroutines ------------------------
|
||||
REM --------------------------------------------------------------
|
||||
:CreatePowerShellRuntimeScript
|
||||
REM GENERIC STARTING PART
|
||||
SET Item=%1
|
||||
ECHO -
|
||||
ECHO Creating PowerShellRuntimeScript for: %Item%
|
||||
ECHO #Automatic generated PowerShellRuntimeScript>%PowerShellRuntimeScript%
|
||||
ECHO Clear-Host>%PowerShellRuntimeScript%
|
||||
ECHO $UserName=^"%RunASUserName%^">>%PowerShellRuntimeScript%
|
||||
ECHO $UserPassword=^"%RunAsUserPassword%^">>%PowerShellRuntimeScript%
|
||||
ECHO $Item=(Get-Item %Item%)>>%PowerShellRuntimeScript%
|
||||
ECHO $Credentials = New-Object System.Management.Automation.PSCredential -ArgumentList @($UserName,(ConvertTo-SecureString -String $UserPassword -AsPlainText -Force))>>%PowerShellRuntimeScript%
|
||||
ECHO.>>%PowerShellRuntimeScript%
|
||||
REM BLOCK FOR CMD FILES
|
||||
IF NOT x%Item:.cmd=%==x%Item% (
|
||||
ECHO #Runtime File is exclusive build for %SearchFileFilter%>>%PowerShellRuntimeScript%
|
||||
ECHO $Process = New-Object System.Diagnostics.Process>>%PowerShellRuntimeScript%
|
||||
ECHO $Process.StartInfo.Filename = ^"cmd.exe^">>%PowerShellRuntimeScript%
|
||||
IF [%RunASUserName%] EQU [] (
|
||||
ECHO #Start Process in current context.>>%PowerShellRuntimeScript%
|
||||
ECHO.>>%PowerShellRuntimeScript%
|
||||
ECHO $Process.StartInfo.UseShellExecute = $True>>%PowerShellRuntimeScript%
|
||||
) ELSE (
|
||||
ECHO #Start Process in RunAs context.>>%PowerShellRuntimeScript%
|
||||
ECHO $Process.StartInfo.UserName = $Credentials.UserName>>%PowerShellRuntimeScript%
|
||||
ECHO $Process.StartInfo.Password = $Credentials.Password>>%PowerShellRuntimeScript%
|
||||
ECHO $Process.StartInfo.UseShellExecute = $False>>%PowerShellRuntimeScript%
|
||||
ECHO $Process.StartInfo.LoadUserProfile = $True>>%PowerShellRuntimeScript%
|
||||
)
|
||||
ECHO $Process.StartInfo.Arguments = "/c ""$($Item.FullName)""">>%PowerShellRuntimeScript%
|
||||
ECHO #$Process.StartInfo.RedirectStandardOutput = $False>>%PowerShellRuntimeScript%
|
||||
ECHO #$Process.StartInfo.RedirectStandardError = $True>>%PowerShellRuntimeScript%
|
||||
ECHO $Process.Start^(^)>>%PowerShellRuntimeScript%
|
||||
)
|
||||
REM BLOCK FOR PS1 FILES
|
||||
IF NOT x%Item:.ps1=%==x%Item% (
|
||||
ECHO #Runtime File is exclusive build for %SearchFileFilter%>>%PowerShellRuntimeScript%
|
||||
ECHO $Process = New-Object System.Diagnostics.Process>>%PowerShellRuntimeScript%
|
||||
ECHO $Process.StartInfo.Filename = ^"powershell.exe^">>%PowerShellRuntimeScript%
|
||||
IF [%RunASUserName%] EQU [] (
|
||||
ECHO #Start Process in current context.>>%PowerShellRuntimeScript%
|
||||
ECHO.>>%PowerShellRuntimeScript%
|
||||
ECHO $Process.StartInfo.UseShellExecute = $True>>%PowerShellRuntimeScript%
|
||||
) ELSE (
|
||||
ECHO #Start Process in RunAs context.>>%PowerShellRuntimeScript%
|
||||
ECHO $Process.StartInfo.UserName = $Credentials.UserName>>%PowerShellRuntimeScript%
|
||||
ECHO $Process.StartInfo.Password = $Credentials.Password>>%PowerShellRuntimeScript%
|
||||
ECHO $Process.StartInfo.UseShellExecute = $False>>%PowerShellRuntimeScript%
|
||||
ECHO $Process.StartInfo.LoadUserProfile = $True>>%PowerShellRuntimeScript%
|
||||
)
|
||||
ECHO $Process.StartInfo.Arguments = "-ExecutionPolicy Bypass -file ""$($Item.FullName)""">>%PowerShellRuntimeScript%
|
||||
ECHO #$Process.StartInfo.RedirectStandardOutput = $False>>%PowerShellRuntimeScript%
|
||||
ECHO #$Process.StartInfo.RedirectStandardError = $True>>%PowerShellRuntimeScript%
|
||||
ECHO $Process.Start^(^)>>%PowerShellRuntimeScript%
|
||||
)
|
||||
REM BLOCK FOR VBS FILES
|
||||
IF NOT x%Item:.vbs=%==x%Item% (
|
||||
ECHO #Runtime File is exclusive build for %SearchFileFilter%>>%PowerShellRuntimeScript%
|
||||
ECHO $Process = New-Object System.Diagnostics.Process>>%PowerShellRuntimeScript%
|
||||
ECHO $Process.StartInfo.Filename = ^"wscript.exe^">>%PowerShellRuntimeScript%
|
||||
IF [%RunASUserName%] EQU [] (
|
||||
ECHO #Start Process in current context.>>%PowerShellRuntimeScript%
|
||||
ECHO.>>%PowerShellRuntimeScript%
|
||||
ECHO $Process.StartInfo.UseShellExecute = $True>>%PowerShellRuntimeScript%
|
||||
) ELSE (
|
||||
ECHO #Start Process in RunAs context.>>%PowerShellRuntimeScript%
|
||||
ECHO $Process.StartInfo.UserName = $Credentials.UserName>>%PowerShellRuntimeScript%
|
||||
ECHO $Process.StartInfo.Password = $Credentials.Password>>%PowerShellRuntimeScript%
|
||||
ECHO $Process.StartInfo.UseShellExecute = $False>>%PowerShellRuntimeScript%
|
||||
ECHO $Process.StartInfo.LoadUserProfile = $True>>%PowerShellRuntimeScript%
|
||||
)
|
||||
ECHO $Process.StartInfo.Arguments = ^"^"^"^"^"^"^"^"^"^"^"^$^(^$Item.FullName^)^"^"^"^"^"^"^"^"^"^"^">>%PowerShellRuntimeScript%
|
||||
ECHO #$Process.StartInfo.RedirectStandardOutput = $False>>%PowerShellRuntimeScript%
|
||||
ECHO #$Process.StartInfo.RedirectStandardError = $True>>%PowerShellRuntimeScript%
|
||||
ECHO $Process.Start^(^)>>%PowerShellRuntimeScript%
|
||||
)
|
||||
REM BLOCK FOR EXE FILES
|
||||
IF NOT x%Item:.exe=%==x%Item% (
|
||||
ECHO #Runtime File is exclusive build for %SearchFileFilter%>>%PowerShellRuntimeScript%
|
||||
ECHO $Process = New-Object System.Diagnostics.Process>>%PowerShellRuntimeScript%
|
||||
ECHO $Process.StartInfo.Filename = ^"^$^(^$Item.FullName^)^">>%PowerShellRuntimeScript%
|
||||
IF [%RunASUserName%] EQU [] (
|
||||
ECHO #Start Process in current context.>>%PowerShellRuntimeScript%
|
||||
ECHO.>>%PowerShellRuntimeScript%
|
||||
ECHO $Process.StartInfo.UseShellExecute = $True>>%PowerShellRuntimeScript%
|
||||
) ELSE (
|
||||
ECHO #Start Process in RunAs context.>>%PowerShellRuntimeScript%
|
||||
ECHO $Process.StartInfo.UserName = $Credentials.UserName>>%PowerShellRuntimeScript%
|
||||
ECHO $Process.StartInfo.Password = $Credentials.Password>>%PowerShellRuntimeScript%
|
||||
ECHO $Process.StartInfo.UseShellExecute = $False>>%PowerShellRuntimeScript%
|
||||
ECHO $Process.StartInfo.LoadUserProfile = $True>>%PowerShellRuntimeScript%
|
||||
)
|
||||
ECHO #$Process.StartInfo.RedirectStandardOutput = $False>>%PowerShellRuntimeScript%
|
||||
ECHO #$Process.StartInfo.RedirectStandardError = $True>>%PowerShellRuntimeScript%
|
||||
ECHO $Process.Start^(^)>>%PowerShellRuntimeScript%
|
||||
)
|
||||
REM GENERIC FINISHING PART
|
||||
IF /i %PowerShellWaitForExit% EQU True (
|
||||
ECHO $Process.WaitForExit^(^)>>%PowerShellRuntimeScript%
|
||||
) ELSE (
|
||||
ECHO #$Process.WaitForExit^(^)>>%PowerShellRuntimeScript%
|
||||
)
|
||||
ECHO #[string] $Out = $Process.StandardOutput.ReadToEnd();>>%PowerShellRuntimeScript%
|
||||
ECHO.>>%PowerShellRuntimeScript%
|
||||
ECHO Remove-Variable -Name UserName -Force -ErrorAction SilentlyContinue>>%PowerShellRuntimeScript%
|
||||
ECHO Remove-Variable -Name UserPassword -Force -ErrorAction SilentlyContinue>>%PowerShellRuntimeScript%
|
||||
ECHO Remove-Variable -Name Item -Force -ErrorAction SilentlyContinue>>%PowerShellRuntimeScript%
|
||||
ECHO Remove-Variable -Name Credentials -Force -ErrorAction SilentlyContinue>>%PowerShellRuntimeScript%
|
||||
ECHO Remove-Variable -Name Process -Force -ErrorAction SilentlyContinue>>%PowerShellRuntimeScript%
|
||||
ECHO.
|
||||
ECHO Starting RuntimeFile: %PowerShellRuntimeScript%
|
||||
%PowerShellCMD% %PowerShellRuntimeScript%
|
||||
DEL %PowerShellRuntimeScript%
|
||||
GOTO :eof
|
||||
REM --------------------------------------------------------------
|
||||
|
||||
REM --------------------------------------------------------------
|
||||
REM ------------------------- main part --------------------------
|
||||
REM --------------------------------------------------------------
|
||||
:mainpart
|
||||
cls
|
||||
ECHO -
|
||||
ECHO Program Startup: %ScriptName% on %computername%,
|
||||
ECHO from Account: %userdomain%\%username%.
|
||||
ECHO On %date% at %time:~0,8% o'clock.
|
||||
|
||||
REM Count Files and show Counter
|
||||
FOR /F "tokens=*" %%f in ('dir /S /b "%SearchPath%\%SearchFileFilter%"') do (set /a Counter+=1)
|
||||
ECHO -
|
||||
ECHO Found %Counter% File(s) with File extension %SearchFileFilter% in Directory:
|
||||
ECHO %SearchPath%
|
||||
|
||||
REM If Counter greater then 0 call subroutine for every found file
|
||||
IF %Counter% GTR 0 (
|
||||
FOR /F "tokens=*" %%f in ('dir /S /b "%SearchPath%\%SearchFileFilter%"') DO (Call :CreatePowerShellRuntimeScript "%%f")
|
||||
GOTO PlanedExit
|
||||
) ELSE (
|
||||
ECHO -
|
||||
ECHO Found no Files. Exiting...
|
||||
GOTO UnplanedExit
|
||||
)
|
||||
REM --------------------------------------------------------------
|
||||
|
||||
REM --------------------------------------------------------------
|
||||
REM ----------------------- finishing part -----------------------
|
||||
REM --------------------------------------------------------------
|
||||
:UnplanedExit
|
||||
endlocal
|
||||
ECHO -
|
||||
ECHO This Window will close in:
|
||||
timeout /T 10
|
||||
rem pause
|
||||
exit
|
||||
|
||||
:PlanedExit
|
||||
endlocal
|
||||
rem pause
|
||||
exit
|
||||
REM --------------------------------------------------------------
|
||||
@@ -0,0 +1,23 @@
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
Version 1.0.0.0 - 22.06.2018 (VBS Version)
|
||||
NEW: -
|
||||
FIX: -
|
||||
CHG: -
|
||||
REM: -
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
Version 1.0.0.0 - 03.06.2018 (CMD Version)
|
||||
NEW: -
|
||||
FIX: -
|
||||
CHG: -
|
||||
REM: -
|
||||
|
||||
-------------------------------------legend------------------------------------
|
||||
NEW: = Added a new functionality
|
||||
FIX: = Fixed a Issue with existing functionality
|
||||
CHG: = Changed a existing functionality
|
||||
REM: = Removed a functionality
|
||||
-------------------------------------------------------------------------------
|
||||
@@ -0,0 +1,10 @@
|
||||
[Folder]
|
||||
SearchPath = P:\Skriptentwickung\released-and-published\Start-ExeOrScriptFile(s)\Test_Files
|
||||
|
||||
[Command]
|
||||
#Filter = *.ps1
|
||||
Filter = Test.ps1;Test1.ps1;test2.vbs
|
||||
#Filter = *.vbs
|
||||
|
||||
[Functionen]
|
||||
Waiting = 1
|
||||
@@ -0,0 +1,91 @@
|
||||
' VB Script Document
|
||||
option explicit
|
||||
'
|
||||
' Digital Data
|
||||
' Ludwig-Rinn-Strasse 16
|
||||
' 35452 Heuchelheim
|
||||
' Tel.: 0641 / 202360
|
||||
' E-Mail: info@didalog.de
|
||||
'
|
||||
' Version Number: 1.0.0.0
|
||||
' Version Date: 04.07.2018
|
||||
|
||||
Const cOrdnertrennzeichen = "\"
|
||||
Const cSeachString = "*"
|
||||
Const cPowershell = "powershell.exe -ExecutionPolicy Bypass -file "
|
||||
|
||||
'-------------------- Diese Konstanten müssen angepasst werden ---------------------------------------------------'
|
||||
Const cSettingsPath = "P:\Skriptentwickung\released-and-published\Start-ExeOrScriptFile\Start-ExeOrScriptFile_Settings.ini"
|
||||
'-----------------------------------------------------------------------------------------------------------------'
|
||||
|
||||
Dim Shell, FSO, IniFile, FSOFile, FSOFolder_Search
|
||||
Dim vZeile, vArr_Zeile, i
|
||||
Dim vWaiting, vFilter, vArr_Filter, vPos, vExtension
|
||||
|
||||
On Error resume next
|
||||
If Err.Number = 0 Then
|
||||
Set FSO = CreateObject("Scripting.FileSystemObject")
|
||||
Set Shell = CreateObject("WScript.Shell")
|
||||
|
||||
'---------------- INI-Datei auslesen -------------------------------------------------------------------------'
|
||||
Set IniFile = FSO.OpenTextFile(cSettingsPath, 1)
|
||||
Do
|
||||
vZeile = IniFile.ReadLine()
|
||||
If Len(vZeile) > 0 Then
|
||||
vArr_Zeile = Split(vZeile, "=")
|
||||
If Left(Trim(vArr_Zeile(0)),1) <> "[" Then
|
||||
Select Case UCase(Trim(vArr_Zeile(0)))
|
||||
Case UCase("SearchPath")
|
||||
Set FSOFolder_Search = FSO.GetFolder(Trim(vArr_Zeile(1)))
|
||||
Case UCase("Filter")
|
||||
vFilter = CStr(Trim(vArr_Zeile(1)))
|
||||
Case UCase("Waiting")
|
||||
vWaiting = CBool(CInt(Trim(vArr_Zeile(1))))
|
||||
End Select
|
||||
End If
|
||||
End If
|
||||
Loop Until IniFile.AtEndOfStream = True
|
||||
IniFile.Close
|
||||
'-------------------------------------------------------------------------------------------------------------'
|
||||
|
||||
'---------------- Programme anhand Filter ausführen ----------------------------------------------------------'
|
||||
vPos = InStr(1,vFilter,cSeachString,0)
|
||||
If vPos > 0 Then
|
||||
vExtension = UCase(Mid(vFilter,vPos + 2))
|
||||
For Each FSOFile In FSOFolder_Search.Files
|
||||
If UCase(FSO.GetExtensionName(FSOFile)) = vExtension Then '-- alle Dateien nach dem Filter überprüfen'
|
||||
If UCase(FSO.GetExtensionName(FSOFile)) = "VBS" Then
|
||||
'Shell.Run """" & FSOFolder_Search & cOrdnertrennzeichen & FSO.GetFileName(FSOFile) & """",0,vWaiting
|
||||
Msgbox """" & FSOFolder_Search & cOrdnertrennzeichen & FSO.GetFileName(FSOFile) & """" & ", 0, " & CStr(vWaiting)
|
||||
ElseIf UCase(FSO.GetExtensionName(FSOFile)) = "PS1" Then
|
||||
'Shell.Run cPowershell & """" & FSOFolder_Search & cOrdnertrennzeichen & FSO.GetFileName(FSOFile) & """",0,vWaiting
|
||||
Msgbox cPowershell & """" & FSOFolder_Search & cOrdnertrennzeichen & FSO.GetFileName(FSOFile) & """" & ", 0, " & CStr(vWaiting)
|
||||
Else
|
||||
'Shell.Run """" & FSOFolder_Search & cOrdnertrennzeichen & FSO.GetFileName(FSOFile) & """",0,vWaiting
|
||||
Msgbox """" & FSOFolder_Search & cOrdnertrennzeichen & FSO.GetFileName(FSOFile) & """" & ", 0, " & CStr(vWaiting)
|
||||
End If
|
||||
End If
|
||||
Next
|
||||
Else
|
||||
vArr_Filter = Split(vFilter, ";")
|
||||
For i = 0 To Ubound(vArr_Filter)
|
||||
If FSO.FileExists(FSOFolder_Search & cOrdnertrennzeichen & FSO.GetFileName(vArr_Filter(i))) = True Then
|
||||
If UCase(FSO.GetExtensionName(FSOFolder_Search & cOrdnertrennzeichen & FSO.GetFileName(vArr_Filter(i)))) = "PS1" Then
|
||||
'Shell.Run cPowershell & """" & FSOFolder_Search & cOrdnertrennzeichen & FSO.GetFileName(vArr_Filter(i)) & """",0,vWaiting
|
||||
Msgbox cPowershell & """" & FSOFolder_Search & cOrdnertrennzeichen & FSO.GetFileName(vArr_Filter(i)) & """" & ", 0, " & CStr(vWaiting)
|
||||
Else
|
||||
'Shell.Run """" & FSOFolder_Search & cOrdnertrennzeichen & FSO.GetFileName(vArr_Filter(i)) & """",0,vWaiting
|
||||
Msgbox """" & FSOFolder_Search & cOrdnertrennzeichen & FSO.GetFileName(vArr_Filter(i)) & """" & ", 0, " & CStr(vWaiting)
|
||||
End If
|
||||
End If
|
||||
Next
|
||||
End If
|
||||
'-------------------------------------------------------------------------------------------------------------'
|
||||
|
||||
Set FSOFolder_SearchPath = Nothing
|
||||
Set IniFile = Nothing
|
||||
Set FSO = Nothing
|
||||
Set Shell = Nothing
|
||||
Else
|
||||
MsgBox(Err.Description)
|
||||
End If
|
||||
Reference in New Issue
Block a user