8
0

Install-WindowsService: Readme added, New Batch Caller, now with admin and PS 7 support

This commit is contained in:
KammM 2024-11-23 19:28:16 +01:00
parent 4815bea47d
commit 3ec35d447d
3 changed files with 140 additions and 41 deletions

View File

@ -1,45 +1,135 @@
TITLE DIGITAL DATA - Run all files in directory
@ECHO OFF
TITLE DIGITAL DATA - Run all files in directory with current permissions
ECHO -
ECHO Batch Script
ECHO Run all files in directory with current permissions
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 1.0.0.0
ECHO Date: 13.08.2015
ECHO -
ECHO Program Startup %date% at %time:~0,8% oclock, on %computername%.
REM ----------------------------------------------------------------------------
REM This script runs all specified files in the current directory
REM
REM Returns: <NOTHING>
REM ----------------------------------------------------------------------------
REM Copyright (c) 2024 by Digital Data GmbH
REM
REM Digital Data GmbH • Ludwig-Rinn-Strasse 16 • D-35452 Heuchelheim
REM Tel.: 0641/202360 • E-Mail: info-flow@digitaldata.works
REM ----------------------------------------------------------------------------
REM Creation Date / Author: 13.08.2015 / MK
REM Version Date / Editor: 23.11.2024 / MK
REM Version Number: 2.0.0.0
REM --------------------------------------------------------------
REM ------------------------set variables-------------------------
REM --------------------------------------------------------------
setlocal enableextensions
SET FILEEXTENSION=*.ps1
SET POWERSHELLEXE="C:\Program Files\PowerShell\7\pwsh.exe"
SET /A ADMINMODE=1
SET DIRECTORY="%cd%"
SET FILEEXTENSION=*.ps1
SET COUNT=0
SET /A COUNT=0
SET LOGFILE="%cd%\error.log"
REM --------------------------------------------------------------
REM ---------------------Program 1 / Script 1---------------------
REM ------------------------preparing part------------------------
REM --------------------------------------------------------------
FOR /F "tokens=*" %%f in ('dir /S /b %FILEEXTENSION%') do (ECHO %%f && set /a count+=1)
SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION
ECHO Program Startup %date% at %time:~0,8% o'clock, on %computername%.
ECHO -
IF !ADMINMODE! EQU 1 (ECHO WARNING: In AdminMode, network drives will maybe unavailable! && timeout /T 10)
REM --------------------------------------------------------------
REM ---------------------Running Scripts---------------------------
REM --------------------------------------------------------------
FOR /F "tokens=*" %%f in ('dir /S /b %FILEEXTENSION%') do (
ECHO %%f
SET /a COUNT+=1
)
ECHO -
ECHO Found %count% File(s) with File Extension %FILEEXTENSION% in Directory:
ECHO %DIRECTORY%.
ECHO Found %COUNT% File(s) with File Extension %FILEEXTENSION% in Directory:
ECHO %DIRECTORY%
ECHO -
ECHO Running this/them now, with your permissions!
FOR /F "tokens=*" %%f in ('dir /S /b %FILEEXTENSION%') do (PowerShell.exe -Command "& {Start-Process 'C:\Program Files\PowerShell\7\pwsh.exe' -Verb runAs '-ExecutionPolicy Bypass -File "%%f"'}")
IF EXIST "!POWERSHELLEXE!" (
ECHO Running these scripts now:
FOR /F "tokens=*" %%f in ('dir /S /b %FILEEXTENSION%') do (
ECHO -
SET "SCRIPT=%%f"
ECHO Running script:
ECHO !SCRIPT!
ECHO -
SET "ARGUMENTS=-NoProfile -ExecutionPolicy Bypass -File \""!SCRIPT!\"""
ECHO With Arguments:
ECHO !ARGUMENTS!
ECHO -
SET "SUBCOMMAND=Start-Process -FilePath '!POWERSHELLEXE!' -ArgumentList '!ARGUMENTS!' "
ECHO Subcommand:
ECHO !SUBCOMMAND!
ECHO -
IF !ADMINMODE! EQU 1 (
SET "COMMAND=Start-Process powershell.exe -Verb runas {!SUBCOMMAND!} "
) ELSE (
SET "COMMAND=Start-Process powershell.exe {!SUBCOMMAND!} "
)
ECHO In nested command:
ECHO !COMMAND!
powershell.exe -NoProfile -ExecutionPolicy Bypass -Command "!COMMAND!"
IF ERRORLEVEL 1 (
ECHO There was an error running the script: !SCRIPT! >> !LOGFILE!
)
)
) ELSE (
ECHO WARNING specified POWERSHELLEXE-Path does not exist or access denied!
ECHO Falling back to build in Powershell Version.
timeout /T 30
ECHO Running these scripts now:
FOR /F "tokens=*" %%f in ('dir /b %FILEEXTENSION%') do (
ECHO -
SET "SCRIPT=%%f"
ECHO Running script:
ECHO !SCRIPT!
ECHO -
SET "ARGUMENTS=-NoProfile -ExecutionPolicy Bypass -File \""!SCRIPT!\"""
ECHO With Arguments:
ECHO !ARGUMENTS!
ECHO -
SET "SUBCOMMAND=Start-Process -FilePath 'powershell.exe' -ArgumentList '!ARGUMENTS!' "
ECHO Subcommand:
ECHO !SUBCOMMAND!
ECHO -
IF !ADMINMODE! EQU 1 (
SET "COMMAND=Start-Process powershell.exe -Verb runas {!SUBCOMMAND!} "
) ELSE (
SET "COMMAND=Start-Process powershell.exe {!SUBCOMMAND!} "
)
ECHO In nested command:
ECHO !COMMAND!
powershell.exe -NoProfile -ExecutionPolicy Bypass -Command "!COMMAND!"
IF ERRORLEVEL 1 (
ECHO There was an error running the script: !SCRIPT! >> !LOGFILE!
)
)
)
REM --------------------------------------------------------------
REM -------------------------final part---------------------------
REM --------------------------------------------------------------
ENDLOCAL
ECHO -
ECHO This Window will close in:
#timeout /T 10
endlocal
exit
ECHO Program Complete %date% at %time:~0,8% o'clock, on %computername%.
ECHO This Window will close in:
timeout /T 10
exit

View File

@ -0,0 +1,5 @@
System Requirements
- PowerShell Version 6 or higher needs to be installed
The path of the Powershell Exe needs to be set in the "Install-WindowsService_Caller.cmd" file.
Like: SET POWERSHELLEXE="C:\Program Files\PowerShell\7\pwsh.exe"

View File

@ -45,6 +45,8 @@ LogFileKeepTime = 30
####################################################################################################
# InstallServiceProfile #
# This profile type installs or updates existing services and starts them if needed. #
# Updating a service can not overwrite the <FullPathToEXE>, in case a path needs to be changed, #
# uninstall and install the service again! #
####################################################################################################
# First Parameter: <ServiceDisplayName> #
# Set the service display name, you want to install. #
@ -95,6 +97,15 @@ LogFileKeepTime = 30
# Example: securepassword #
####################################################################################################
UninstallServiceProfile = DigitalDataEmail-Service
#InstallServiceProfile = Digital Data Email-Service ; D:\ProgramFiles\Digital Data\Debug\DDEmailService.exe ; ; Manual ; InstallAndStart ; Sends emails from the Digital Data email pool.
#Example:
#UninstallServiceProfile = MyNiceService
#InstallServiceProfile = My nice service ; D:\ProgramFiles\Myniceservice\program.exe ; ;Automatic ; InstallOnly ; This is a very nice service
#InstallServiceProfile = My nice service ; D:\ProgramFiles\Myniceservice\program.exe ; -parameter1 ;Automatic ; InstallAndStart ; This is a very nice service ; domain\user ; password
#UninstallServiceProfile = DigitalDataEB-Creator
#UninstallServiceProfile = DigitalDataEmail-Profiler
#UninstallServiceProfile = DigitalDataeInvoice-Parser
@ -103,17 +114,10 @@ LogFileKeepTime = 30
#UninstallServiceProfile = DigitalDataWM-ResultHandler
#UninstallServiceProfile = DigitalDataEDMI-Service
InstallServiceProfile = Digital Data EB-Creator ; F:\ProgramFiles\Digital Data\DDEBCreator\SERVICE\EB_Creator.exe ; ; Manual ; InstallOnly ; Creates result reports for released documents.
InstallServiceProfile = Digital Data Email-Profiler ; F:\ProgramFiles\Digital Data\DDEmailProfiler\SERVICE\EmailProfiler.Service.exe ; ; Manual ; InstallOnly ; Monitors email inboxes and processes incoming emails and their attachments.
InstallServiceProfile = Digital Data eInvoice-Parser ; F:\ProgramFiles\Digital Data\DDZUGFeRDService\DDZUGFeRDService.exe ; ; Manual ; InstallOnly ; Validates electronic invoices and extracts data.
InstallServiceProfile = Digital Data JobRunner ; F:\ProgramFiles\Digital Data\DDJobRunner\SERVICE\DigitalData.Services.JobRunner.exe ; ; Manual ; InstallOnly ; Executes defined and configured jobs to synchronize master and transaction data.
InstallServiceProfile = Digital Data Email-Service ; F:\ProgramFiles\Digital Data\DDEmailService\SERVICE\DDEmailService.exe ; ; Manual ; InstallOnly ; Sends emails from the Digital Data email pool.
#InstallServiceProfile = Digital Data EB-Creator ; D:\ProgramFiles\Digital Data\DDEBCreator\SERVICE\EB_Creator.exe ; ; Manual ; InstallOnly ; Creates result reports for released documents.
#InstallServiceProfile = Digital Data Email-Profiler ; D:\ProgramFiles\Digital Data\DDEmailProfiler\SERVICE\EmailProfiler.Service.exe ; ; Manual ; InstallOnly ; Monitors email inboxes and processes incoming emails and their attachments.
#InstallServiceProfile = Digital Data eInvoice-Parser ; D:\ProgramFiles\Digital Data\DDZUGFeRDService\DDZUGFeRDService.exe ; ; Manual ; InstallOnly ; Validates electronic invoices and extracts data.
#InstallServiceProfile = Digital Data JobRunner ; D:\ProgramFiles\Digital Data\DDJobRunner\SERVICE\DigitalData.Services.JobRunner.exe ; ; Manual ; InstallOnly ; Executes defined and configured jobs to synchronize master and transaction data.
#InstallServiceProfile = Digital Data Email-Service ; D:\ProgramFiles\Digital Data\DDEmailService\SERVICE\DDEmailService.exe ; ; Manual ; InstallOnly ; Sends emails from the Digital Data email pool.
#InstallServiceProfile = Digital Data WM-ResultHandler ; ; ; Manual ; InstallOnly ; Executes windream searches and processes the results according to profile specifications.
#InstallServiceProfile = Digital Data EDMI-Service ; ; ; Manual ; InstallOnly ; Proxy Service for Digital Data Applications.
#Example:
#UninstallServiceProfile = MyNiceService
#InstallServiceProfile = My nice service ; D:\ProgramFiles\Myniceservice\program.exe ; ;Automatic ; InstallOnly ; This is a very nice service
#InstallServiceProfile = My nice service ; D:\ProgramFiles\Myniceservice\program.exe ; -parameter1 ;Automatic ; InstallAndStart ; This is a very nice service ; domain\user ; password
#InstallServiceProfile = Digital Data EDMI-Service ; ; ; Manual ; InstallOnly ; Proxy Service for Digital Data Applications.