Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- http://www.howtodo-it.de/howtos/Software/microsoft/windows-xp-2000/Programm-als-Dienst-starten
- https://www.youtube.com/watch?v=wlTG48-SBI8
- https://msdn.microsoft.com/de-de/magazine/mt703436.aspx
- https://msdn.microsoft.com/de-de/magazine/mt703436.aspx
- $serviceName = "<Name des Dienstes>"
- $displayName = "<Anzeigename des Dienstes>"
- $description = "<Beschreibung des Dienstes>"
- $exePath = "<D:\Program Files\Dienst\Dienst.exe>"
- $username = "<Dienstkonto>"
- $password = convertto-securestring -String "<Passwort>" -AsPlainText -Force
- $cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $username, $password
- New-Service -BinaryPathName $exePath -Name $serviceName -Description $description -Credential $cred -DisplayName $displayName -StartupType Automatic
- inen Windows-Dienst mittels Powershell anzulegen ist kein allzu schwieriges Unterfangen. Mit folgendem Script ist dies innerhalb weniger Sekunden erledigt.
- PowerShell
- $serviceName = "<Name des Dienstes>"
- $displayName = "<Anzeigename des Dienstes>"
- $description = "<Beschreibung des Dienstes>"
- $exePath = "<D:\Program Files\Dienst\Dienst.exe>"
- $username = "<Dienstkonto>"
- $password = convertto-securestring -String "<Passwort>" -AsPlainText -Force
- $cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $username, $password
- New-Service -BinaryPathName $exePath -Name $serviceName -Description $description -Credential $cred -DisplayName $displayName -StartupType Automatic
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- $serviceName = "<Name des Dienstes>"
- $displayName = "<Anzeigename des Dienstes>"
- $description = "<Beschreibung des Dienstes>"
- $exePath = "<D:\Program Files\Dienst\Dienst.exe>"
- $username = "<Dienstkonto>"
- $password = convertto-securestring -String "<Passwort>" -AsPlainText -Force
- $cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $username, $password
- New-Service -BinaryPathName $exePath -Name $serviceName -Description $description -Credential $cred -DisplayName $displayName -StartupType Automatic
- In die spitzen Klammern musst du nun lediglich noch die Daten deines Dienstes eintragen und dies in einer Admin-Powershell ausführen.
- Der Dienst wird nach dem Anlegen nicht gestartet. Dies kann über die GUI geschehen oder du gibst in einer Admin-CMD-Shell sc start "<Name des Dienstes>" ein.
- Sollte ein Dienst falsch angelegt worden sein und muss vorher gelöscht werden, so geht dies ebenfalls mittels des SC-Befehls.
- sc stop "<Name des Dienstes>" sc delete "<Name des Dienstes>"
- ###############################
- Vorbereitende Schritte
- Für diese Prozedur müssen Sie sich mit einer Benutzer-ID anmelden, die zur Gruppe 'Administratoren' gehört.
- Vorgehensweise
- Gehen Sie wie folgt vor, um einen Windows-Dienst zu erstellen und die Startoptionen für den Dienst zu konfigurieren:
- Öffnen Sie ein Befehlsfenster und geben Sie den Befehl sc.exe create ein:
- sc.exe create Servername binPath= "Serverpfad -k Instanzname"
- sc.exe create Servername binPath= "Serverpfad -k Instanzname"
- start= Starttyp obj= Kontoname password= Kennwort
- copy to clipboard
- Hierbei gilt Folgendes:
- Servername
- Gibt den Namen des Serverdienstes an.
- Serverpfad
- Gibt den Pfad zur ausführbaren Datei dsmsvc.exe und den Dateinamen an. Der Standardpfad lautet:
- C:\Programme\Tivoli\TSM\server
- Instanzname
- Gibt den Namen der DB2-Instanz an, der mit dem Namen der Serverinstanz identisch ist, z. B. Server1.
- Starttyp
- Gibt die Startmethode für den Dienst an. Soll der Dienst automatisch gestartet werden, geben Sie auto ein. Wenn Sie die Option auto angeben, wird der Dienst automatisch beim Systemstart gestartet und bei jedem Neustart des Systems automatisch erneut gestartet. Soll der Dienst manuell gestartet werden, geben Sie demand ein.
- Kontoname
- Gibt die Benutzer-ID für das Konto an, unter dem der Dienst ausgeführt wird. Der Kontoname könnten z. B. 'Administrator' lauten. Dieser Parameter ist wahlfrei. Wird er nicht angegeben, wird das Konto 'Lokales System' verwendet.
- Kennwort
- Gibt das Kennwort für das Benutzerkonto Kontoname an.
- $source = @"
- using System;
- class Hello {
- static void Main() {
- String appFile = @"c:\Program Files\R\R-3.4.1\bin\Rscript.exe";
- String args = @"D:\barcode_app1.R";
- System.Diagnostics.Process.Start(appFile, args);
- }
- }
- "@
- Add-Type -TypeDefinition $source -Language CSharp -OutputAssembly "d:\barcode_test01.exe" -OutputType ConsoleApplication
- C:\PS>
- new-service -name barcode01 -BinaryPathName "D:\barcode_test01.exe" -displayName "barcode01" -StartupType Automatic -Description "Barcode - This is a test service."
- sc.exe create Barcode_XXX binPath= "d:\barcode_test01.exe"
- SC DELETE shortservicename
- sc.exe create Barcode_XXX1 binPath= "cmd /c d:\barcode_test01.exe"
- c:\programlocation\program.exe
- sc.exe create Barcode_XXX2 binPath= "d:\\barcode_test01.exe"
- https://msdn.microsoft.com/de-de/magazine/mt703436.aspx
- $source = @"
- using System;
- class Hello {
- static void Main() {
- Console.WriteLine("Hello World!");
- }
- }
- "@
- Add-Type -TypeDefinition $source -Language CSharp -OutputAssembly "d:\hello01.exe" -OutputType ConsoleApplication
- $source = @"
- using System;
- class Hello {
- static void Main() {
- System.Diagnostics.Process.Start("notepad.exe");
- }
- }
- "@
- Add-Type -TypeDefinition $source -Language CSharp -OutputAssembly "d:\hello02.exe" -OutputType ConsoleApplication
- $source = @"
- using System;
- class Hello {
- static void Main() {
- System.Diagnostics.Process.Start("R.exe");
- }
- }
- "@
- Add-Type -TypeDefinition $source -Language CSharp -OutputAssembly "d:\hello03.exe" -OutputType ConsoleApplication
- $source = @"
- using System;
- class Hello {
- static void Main() {
- System.Diagnostics.Process.Start("Rscript.exe barcode_app1.R");
- }
- }
- "@
- Add-Type -TypeDefinition $source -Language CSharp -OutputAssembly "d:\hello04.exe" -OutputType ConsoleApplication
- $source = @"
- using System;
- class Hello {
- static void Main() {
- System.Diagnostics.Process.Start("Rscript.exe d:\\barcode_app1.R");
- }
- }
- "@
- Add-Type -TypeDefinition $source -Language CSharp -OutputAssembly "d:\hello05.exe" -OutputType ConsoleApplication
- https://technet.microsoft.com/de-de/library/dd315247.aspx
- https://www.colorconsole.de/PS_Windows/de/New-Service.htm
- C:\PS>new-service -name TestService -path "C:\WINDOWS\System32\svchost.exe -k netsvcs" -dependson NetLogon -displayName "Test Service" -StartupType Manual -Description "This is a test service."
- https://www.fmjf.de/2015/05/einen-windows-dienst-mit-powershell-anlegen/
- sc stop "<Name des Dienstes>"
- sc delete "<Name des Dienstes>"
- d:\misc2\bin\Rscript.exe d:\r_code\mycode.r
- install.packages(c("RPostgreSQL", "exifr", "base64enc", "shiny", "shinyjs"))
- suppressMessages(library(shiny))
- ui <- pageWithSidebar(
- headerPanel("Barcode Scanner"),
- sidebarPanel(
- shinyjs::useShinyjs(),
- id = "side-panel",
- textInput("mytext", "Barcode", ""),
- actionButton("reset_input", "SEND"),
- tableOutput('tbl')
- ),
- mainPanel()
- )
- server <- function(input, output, session) {
- dataOut <- reactive({
- DF_return <- data.frame()
- if(input$mytext != "")
- DF_return <- data.frame(barcode = as.character(input$mytext),
- timestamp_scanned = Sys.time(),
- stringsAsFactors = F)
- return(DF_return)
- })
- output$tbl <- renderTable({ dataOut() })
- observeEvent(input$reset_input, {
- DF_return <- dataOut()
- DF_return$timestamp_sent <- Sys.time()
- # - Postgres ----
- server_ip <- "127.0.0.1"
- postgres_port <- 5432
- con <- RPostgreSQL::dbConnect(DBI::dbDriver("PostgreSQL"),
- user ="postgres",
- password = "postgres",
- host = server_ip,
- port = postgres_port,
- dbname = "postgres")
- table_schema <- "image_processing"
- table_name <- "barcode"
- RPostgreSQL::dbWriteTable(con, c(table_schema, table_name), DF_return, append=TRUE, row.names=FALSE)
- RPostgreSQL::dbDisconnect(con)
- # ---------------
- write.table(DF_return, "/home/supi/Schreibtisch/barcode/junk.txt")
- shinyjs::reset("side-panel")
- })
- }
- shinyApp(ui, server, options=list(port=55555))
Add Comment
Please, Sign In to add comment