Guest User

Untitled

a guest
Feb 18th, 2018
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.61 KB | None | 0 0
  1. http://www.howtodo-it.de/howtos/Software/microsoft/windows-xp-2000/Programm-als-Dienst-starten
  2. https://www.youtube.com/watch?v=wlTG48-SBI8
  3. https://msdn.microsoft.com/de-de/magazine/mt703436.aspx
  4. https://msdn.microsoft.com/de-de/magazine/mt703436.aspx
  5.  
  6. $serviceName = "<Name des Dienstes>"
  7. $displayName = "<Anzeigename des Dienstes>"
  8. $description = "<Beschreibung des Dienstes>"
  9. $exePath = "<D:\Program Files\Dienst\Dienst.exe>"
  10. $username = "<Dienstkonto>"
  11. $password = convertto-securestring -String "<Passwort>" -AsPlainText -Force
  12. $cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $username, $password
  13.  
  14. New-Service -BinaryPathName $exePath -Name $serviceName -Description $description -Credential $cred -DisplayName $displayName -StartupType Automatic
  15.  
  16. inen Windows-Dienst mittels Powershell anzulegen ist kein allzu schwieriges Unterfangen. Mit folgendem Script ist dies innerhalb weniger Sekunden erledigt.
  17. PowerShell
  18. $serviceName = "<Name des Dienstes>"
  19. $displayName = "<Anzeigename des Dienstes>"
  20. $description = "<Beschreibung des Dienstes>"
  21. $exePath = "<D:\Program Files\Dienst\Dienst.exe>"
  22. $username = "<Dienstkonto>"
  23. $password = convertto-securestring -String "<Passwort>" -AsPlainText -Force
  24. $cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $username, $password
  25.  
  26. New-Service -BinaryPathName $exePath -Name $serviceName -Description $description -Credential $cred -DisplayName $displayName -StartupType Automatic
  27. 1
  28. 2
  29. 3
  30. 4
  31. 5
  32. 6
  33. 7
  34. 8
  35. 9
  36.  
  37. $serviceName = "<Name des Dienstes>"
  38. $displayName = "<Anzeigename des Dienstes>"
  39. $description = "<Beschreibung des Dienstes>"
  40. $exePath = "<D:\Program Files\Dienst\Dienst.exe>"
  41. $username = "<Dienstkonto>"
  42. $password = convertto-securestring -String "<Passwort>" -AsPlainText -Force
  43. $cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $username, $password
  44.  
  45. New-Service -BinaryPathName $exePath -Name $serviceName -Description $description -Credential $cred -DisplayName $displayName -StartupType Automatic
  46.  
  47. In die spitzen Klammern musst du nun lediglich noch die Daten deines Dienstes eintragen und dies in einer Admin-Powershell ausführen.
  48. 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.
  49.  
  50. Sollte ein Dienst falsch angelegt worden sein und muss vorher gelöscht werden, so geht dies ebenfalls mittels des SC-Befehls.
  51. sc stop "<Name des Dienstes>" sc delete "<Name des Dienstes>"
  52.  
  53. ###############################
  54.  
  55. Vorbereitende Schritte
  56. Für diese Prozedur müssen Sie sich mit einer Benutzer-ID anmelden, die zur Gruppe 'Administratoren' gehört.
  57. Vorgehensweise
  58.  
  59. Gehen Sie wie folgt vor, um einen Windows-Dienst zu erstellen und die Startoptionen für den Dienst zu konfigurieren:
  60. Öffnen Sie ein Befehlsfenster und geben Sie den Befehl sc.exe create ein:
  61.  
  62.  
  63. sc.exe create Servername binPath= "Serverpfad -k Instanzname"
  64.  
  65. sc.exe create Servername binPath= "Serverpfad -k Instanzname"
  66. start= Starttyp obj= Kontoname password= Kennwort
  67. copy to clipboard
  68.  
  69. Hierbei gilt Folgendes:
  70.  
  71. Servername
  72. Gibt den Namen des Serverdienstes an.
  73. Serverpfad
  74. Gibt den Pfad zur ausführbaren Datei dsmsvc.exe und den Dateinamen an. Der Standardpfad lautet:
  75.  
  76. C:\Programme\Tivoli\TSM\server
  77. Instanzname
  78. Gibt den Namen der DB2-Instanz an, der mit dem Namen der Serverinstanz identisch ist, z. B. Server1.
  79. Starttyp
  80. 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.
  81. Kontoname
  82. 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.
  83. Kennwort
  84. Gibt das Kennwort für das Benutzerkonto Kontoname an.
  85.  
  86.  
  87.  
  88.  
  89. $source = @"
  90. using System;
  91. class Hello {
  92. static void Main() {
  93. String appFile = @"c:\Program Files\R\R-3.4.1\bin\Rscript.exe";
  94. String args = @"D:\barcode_app1.R";
  95. System.Diagnostics.Process.Start(appFile, args);
  96. }
  97. }
  98. "@
  99. Add-Type -TypeDefinition $source -Language CSharp -OutputAssembly "d:\barcode_test01.exe" -OutputType ConsoleApplication
  100.  
  101.  
  102.  
  103. C:\PS>
  104.  
  105. new-service -name barcode01 -BinaryPathName "D:\barcode_test01.exe" -displayName "barcode01" -StartupType Automatic -Description "Barcode - This is a test service."
  106.  
  107.  
  108.  
  109. sc.exe create Barcode_XXX binPath= "d:\barcode_test01.exe"
  110. SC DELETE shortservicename
  111.  
  112.  
  113. sc.exe create Barcode_XXX1 binPath= "cmd /c d:\barcode_test01.exe"
  114.  
  115. c:\programlocation\program.exe
  116.  
  117. sc.exe create Barcode_XXX2 binPath= "d:\\barcode_test01.exe"
  118.  
  119.  
  120.  
  121.  
  122. https://msdn.microsoft.com/de-de/magazine/mt703436.aspx
  123.  
  124.  
  125. $source = @"
  126. using System;
  127. class Hello {
  128. static void Main() {
  129. Console.WriteLine("Hello World!");
  130. }
  131. }
  132. "@
  133. Add-Type -TypeDefinition $source -Language CSharp -OutputAssembly "d:\hello01.exe" -OutputType ConsoleApplication
  134.  
  135. $source = @"
  136. using System;
  137. class Hello {
  138. static void Main() {
  139. System.Diagnostics.Process.Start("notepad.exe");
  140. }
  141. }
  142. "@
  143. Add-Type -TypeDefinition $source -Language CSharp -OutputAssembly "d:\hello02.exe" -OutputType ConsoleApplication
  144.  
  145.  
  146. $source = @"
  147. using System;
  148. class Hello {
  149. static void Main() {
  150. System.Diagnostics.Process.Start("R.exe");
  151. }
  152. }
  153. "@
  154. Add-Type -TypeDefinition $source -Language CSharp -OutputAssembly "d:\hello03.exe" -OutputType ConsoleApplication
  155.  
  156. $source = @"
  157. using System;
  158. class Hello {
  159. static void Main() {
  160. System.Diagnostics.Process.Start("Rscript.exe barcode_app1.R");
  161. }
  162. }
  163. "@
  164. Add-Type -TypeDefinition $source -Language CSharp -OutputAssembly "d:\hello04.exe" -OutputType ConsoleApplication
  165.  
  166.  
  167.  
  168. $source = @"
  169. using System;
  170. class Hello {
  171. static void Main() {
  172. System.Diagnostics.Process.Start("Rscript.exe d:\\barcode_app1.R");
  173. }
  174. }
  175. "@
  176. Add-Type -TypeDefinition $source -Language CSharp -OutputAssembly "d:\hello05.exe" -OutputType ConsoleApplication
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194. https://technet.microsoft.com/de-de/library/dd315247.aspx
  195. https://www.colorconsole.de/PS_Windows/de/New-Service.htm
  196. 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."
  197.  
  198. https://www.fmjf.de/2015/05/einen-windows-dienst-mit-powershell-anlegen/
  199. sc stop "<Name des Dienstes>"
  200. sc delete "<Name des Dienstes>"
  201. d:\misc2\bin\Rscript.exe d:\r_code\mycode.r
  202.  
  203.  
  204. install.packages(c("RPostgreSQL", "exifr", "base64enc", "shiny", "shinyjs"))
  205.  
  206. suppressMessages(library(shiny))
  207.  
  208. ui <- pageWithSidebar(
  209.  
  210. headerPanel("Barcode Scanner"),
  211.  
  212. sidebarPanel(
  213. shinyjs::useShinyjs(),
  214. id = "side-panel",
  215. textInput("mytext", "Barcode", ""),
  216. actionButton("reset_input", "SEND"),
  217. tableOutput('tbl')
  218. ),
  219. mainPanel()
  220. )
  221.  
  222. server <- function(input, output, session) {
  223.  
  224. dataOut <- reactive({
  225. DF_return <- data.frame()
  226. if(input$mytext != "")
  227. DF_return <- data.frame(barcode = as.character(input$mytext),
  228. timestamp_scanned = Sys.time(),
  229. stringsAsFactors = F)
  230. return(DF_return)
  231. })
  232.  
  233. output$tbl <- renderTable({ dataOut() })
  234.  
  235. observeEvent(input$reset_input, {
  236.  
  237. DF_return <- dataOut()
  238. DF_return$timestamp_sent <- Sys.time()
  239.  
  240. # - Postgres ----
  241.  
  242. server_ip <- "127.0.0.1"
  243. postgres_port <- 5432
  244. con <- RPostgreSQL::dbConnect(DBI::dbDriver("PostgreSQL"),
  245. user ="postgres",
  246. password = "postgres",
  247. host = server_ip,
  248. port = postgres_port,
  249. dbname = "postgres")
  250.  
  251. table_schema <- "image_processing"
  252. table_name <- "barcode"
  253. RPostgreSQL::dbWriteTable(con, c(table_schema, table_name), DF_return, append=TRUE, row.names=FALSE)
  254. RPostgreSQL::dbDisconnect(con)
  255.  
  256. # ---------------
  257.  
  258. write.table(DF_return, "/home/supi/Schreibtisch/barcode/junk.txt")
  259.  
  260. shinyjs::reset("side-panel")
  261. })
  262. }
  263.  
  264. shinyApp(ui, server, options=list(port=55555))
Add Comment
Please, Sign In to add comment