Jump to content

Eddi96

Members
  • Posts

    18
  • Joined

  • Last visited

Eddi96's Achievements

Seeker

Seeker (1/7)

0

Reputation

  1. @SadBunny Thank you alot! That is exactly what I needed! With your help I am now able to read the ID of a user, given as parameter, and then combine it with logoff and my backup script!
  2. Hello guys! #include <Array.au3> #include <File.au3> $iBenutzername = $Var_cmdline ; I need this to be the variable given as a parameter. ; I've read alot about CmdLine but can't think of a way to define a variable with it ; I hope you have an Idea on how to do it! Much love <3 Global $sFile = "C:\GTScript\query.txt" Global $aUsers _FileReadToArray($sFile, $aUsers, $FRTA_NOCOUNT) _ArrayColInsert($aUsers, 1) _ArrayColInsert($aUsers, 1) _ArrayColInsert($aUsers, 1) _ArrayColInsert($aUsers, 1) _ArrayColInsert($aUsers, 1) _ArrayColInsert($aUsers, 1) For $i = 0 To UBound($aUsers) - 1 $aSplit = StringRegExp($aUsers[$i][0], "(\S+)", $STR_REGEXPARRAYGLOBALMATCH) For $j = 0 To UBound($aSplit)-1 $aUsers[$i][$j] =$aSplit[$j] Next $aUsers[$i][0]=StringReplace($aUsers[$i][0],'>','') Next $sUser=$iBenutzername Func _FindUserID($aArray,$sSearch) Local $iRow=_ArraySearch($aArray,$sUser) If @error Then Return SetError(@error,-1,'') Local $sID=$aArray[$iRow][2] Return SetError(0,$iRow,$sID) EndFunc MsgBox(64,'Searcher UserID '&$sUser,_FindUserID($aUsers,$sUser))
  3. Hey AutoBert thank you for your response, so I tested your code and the only thing that happens is that it displays the Array. I tried to ask for the $sID with a MsgBox but the box doesnt show
  4. Hello World! So I have this code #include <Array.au3> Run("C:\Windows\System32\query user>>c:\GTScript\query.txt") $aFileArray = FileReadToArray("c:\GTScript\query.txt") -1 ; NOTE: the first line of the file is in element 0, but that only holds column headers so we start from 1! For $lineIndex = 1 to UBound($aFileArray) ; Let's take every group of non-whitespace characters from the current line and put it in an array: $aSplit = StringRegExp($aFileArray[$lineIndex], "(\S+)", $STR_REGEXPARRAYGLOBALMATCH) _ArrayDisplay($aSplit, "All elements on line") ; We know the format of the file, so we know where the values will be in the array: $userName = $aSplit[0] $userId = $aSplit[2] MsgBox(64, "Info", "Username: " & $userName & @CRLF & "ID: " & $userId) Next Do you have an Idea on how to rewrite it so it allways tells me row 2 of a certain user, no matter in which Column of ArrayDisplay he is? Post examples please, since I am still a rookie! With kind regards Eddi96
  5. Hey people, thank you all for you help but I have another challange right now. #include <Array.au3> $aFileArray = FileReadToArray("c:\tmp\x.txt") ; NOTE: the first line of the file is in element 0, but that only holds column headers so we start from 1! For $lineIndex = 1 to UBound($aFileArray) ; Let's take every group of non-whitespace characters from the current line and put it in an array: $aSplit = StringRegExp($aFileArray[$lineIndex], "(\S+)", $STR_REGEXPARRAYGLOBALMATCH) _ArrayDisplay($aSplit, "All elements on line") ; We know the format of the file, so we know where the values will be in the array: $userName = $aSplit[0] $userId = $aSplit[2] MsgBox(64, "Info", "Username: " & $userName & @CRLF & "ID: " & $userId) Next This is the Code im working with, but the Problem is: I need to rewrite it because we dont know where the needed ID is. We know how the File is built and we know that the ID is always in the same row with the Username, the problem I have right now is that I don't know how to read for a certain Username and then read the ID from that row. Can you please help me with that?
  6. #RequireAdmin #include <Array.au3> Run("C:\Windows\System32\query user>>c:\GTScript\tempID1.txt") $aFileArray = FileReadToArray("c:\GTScript\tempID1.txt") For $lineIndex = 1 to UBound($aFileArray) - 1 $aSplit = StringRegExp($aFileArray[$lineIndex], "(\S+)", $STR_REGEXPARRAYGLOBALMATCH) $userName = $aSplit[0] $userId = $aSplit[2] FileOpen("c:\GTScript\tempID2.txt", 2) $Sek = 1 sleep($Sek * 500) FileWrite("c:\GTScript\tempID2.txt", $userId) FileDelete("c:\GTScript\tempID1.txt") Next So i found the solution. you had to add C:\Windows\System32\
  7. So I have another Problem, when I use Run ("C:\Users\wg\Desktop\GTScript\TEMPquery.bat") the bat file: query user>>c:\users\wg\desktop\GTScript\tempID1.txt It doesnt write the text... But if i just start it with my mouse, it does write the text. I don't get why it does it, do you have another way of running a batch through autoit?
  8. Hey Sad Bunny, thanks for the quick response but when I rewrote it and started it, it gives me the right ID but also an Error : Array variable has incorrect number of subscirpts or subscript dimension range exceeded. Any Idea on why it does this?
  9. Hey guys! I need your help again. So I am working on a Project with which I can Logoff a User in a Terminal-Server (Windows Server 2012 R2), logged in as Admin. Then backup the users partition and log him back in. Sounds pretty easy for you guys, right? So my problem is... I seem to not be able to get the User ID. You can see and display the ID in a textfile with: Run("query user>>c:\users\example\desktop\helpmeguys.txt") This line just writes a textfile of "query user" on the desktop. This is an example on what it looks like: BENUTZERNAME SITZUNGSNAME ID STATUS LEERLAUF ANMELDEZEIT >wg console 2 Aktiv 17 25.07.2016 08:19 What I need right now is the ID. Any Idea on how to read it off of the Textfile? Please give me examples because I am still a rookie! With kind regards Eddi96
  10. It's not inteded for external use. This is just a little tool me and my collegues will use to automate our backup and revision. Sorry for language Switching, Wir sind hier alle Fachinformatiker Systemintegration/Anwendungsentwicklung. Das war bloß ein kleines Projekt für mich und um das Programm, welches wir betreiben , näher kennenzulernen. Ich bin selber Noch Azubi und habe am 13.Juni angefangen
  11. You can try to use the AutoIt Window Info to read the class. What I would do is to simulate a Mouseclick on the Window with Winwait so it switches the focus. Here is an Example Opt("WinWait",3) WinWait("Example-Explorer") MouseClick ($MOUSE_CLICK_PRIMARY[, clicks = 1]) You might want to check if that's working you can just use F1 in AutoIt and look for MouseClick
  12. I found the mistake, it takes some time until the actual programm finishes the Logfile, I just had to add a sleep. Thank you so much guys!!! Love you all! Here is the finished code in case someone wants to see how I used the function above. I hope it helps! #RequireAdmin #NoTrayIcon #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <String.au3> #include <MsgBoxConstants.au3> #include <StringConstants.au3> #include <File.au3> Test() Func Test() ; Das GUI Local $hGUI = GUICreate("Test", 300, 200) ; Erstellung der Buttons Local $idRevision = GUICtrlCreateButton("Datenrevision", 30, 170, 85, 25) Local $idExpress = GUICtrlCreateButton("ExpressDasi", 120, 170, 85, 25) Local $idClose = GUICtrlCreateButton("Close", 210, 170, 85, 25) ; Darstellung des GUI GUISetState(@SW_SHOW, $hGUI) Local $iPID = 0 ; Loop bis der benutzer auf Close drückt While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $idClose ExitLoop Case $idRevision Revision() Case $idExpress Express() EndSwitch WEnd ; Delete the previous GUI and all controls. GUIDelete($hGUI) ; Close the Notepad process using the PID returned by Run. If $iPID Then ProcessClose($iPID) EndFunc Func Testing() Local $aRetArray, $sFilePath = ("C:\THEORG\THEORG\LOGS\TADMINEvent.log") ; Pfad zur LogDatei _FileReadToArray($sFilePath, $aRetArray) Local $i = $aRetArray[0] -2 ; Position des Strings (last line - 2) Local $sStr1 = $aRetArray[$i] ; Liest die Position Local $sStr2 = FileReadLine("C:\THEORG\THEORG\LOGS\Vergleich.txt", 1) ; Pfad zum Vergleich und die Zeile 1 zum lesen ConsoleWrite("$sStr1 = " & $sStr1 & @CRLF) ; Test ConsoleWrite("$sStr2 = " & $sStr2 & @CRLF) ; Test ; wenn $iCmp = 0 dann stimmt das Ergebnis ; Vergleich der beiden Strings $iCmp = StringCompare($sStr1, $sStr2, $STR_CASESENSE) $Sek = 1 Sleep($Sek * 2000);2 sekunden später If $iCmp = 0 Then Run("C:\theorg\theorg\TADMIN /UNLOCKSYSTEM") ; Öffnet THEORG wieder für alle Benutzer MsgBox(64, "InfoBox", "Die Datenrevision wurde erfolgreich durchgeführt und das Programm ist nun wieder verwendbar") Else MsgBox(64, "InfoBox", "Die Datenrevision ist Fehlgeschlagen, bitte Fragen Sie Ihren EDV Betreuer nach Auskunft!") EndIf EndFunc Func Express() MsgBox(64, "InfoBox", "THEORG wird nun für alle Benutzer gesperrt.") Opt("WinWait",3) ; Gibt an, dass WinWait auf einen bestimmten Titel reagiert Run("C:\theorg\theorg\TADMIN /SHUTDOWN=5") ; Startet den Shutdown anderer Benutzer im THEORG und ; sperrt die Benutzung bis UNLOCK durchgeführt wird. Run("C:\THEORG\SUPPORT\BACKUP\TBSYS.EXE /SERVICE") ; WinWait("THEORG-Datensicherung") ; Wartet mit der Durchführung der Tastenanschläge bis das Fenster "THEORG-Datensicherung" offen ist. $Sek = 1 Sleep($Sek * 5000);5 sekunden später ControlSend("THEORG-Datensicherung","",0,"{ENTER}") $Sek = 1 Sleep($Sek * 500);0,5 sekunden später ControlSend("THEORG Datensicherung erstellen","",0,"{DOWN}") $Sek = 1 Sleep($Sek * 500);0,5 sekunden später ControlSend("THEORG Datensicherung erstellen","",0,"{ENTER}") $Sek = 1 Sleep($Sek * 500);0,5 sekunden später ControlSend("THEORG Datensicherung erstellen","",0,"{ENTER}") $Sek = 1 Sleep($Sek * 500);0,5 sekunden später ControlSend("THEORG Datensicherung erstellen","",0,"{ENTER}") $Sek = 1 Sleep($Sek * 500);0,5 sekunden später ControlSend("THEORG Datensicherung erstellen","",0,"{ENTER}") $Sek = 1 Sleep($Sek * 500);0,5 sekunden später ; ControlSend("Bestätigung","",0,"{RIGHT}") ; Diese zwei Tastenanschläge sorgen für die ; nicht überschreibung der zuvor $Sek = 1 ; durchgeführten Express Datensicherung. Sleep($Sek * 500);0,5 sekunden später ; ControlSend("Bestätigung","",0,"{ENTER}") ; $Sek = 1 Sleep($Sek * 500);0,5 sekunden später ControlSend("THEORG Datensicherung erstellen","",0,"{ENTER}") $Sek = 1 Sleep($Sek * 500);0,5 sekunden später ControlSend("THEORG Datensicherung erstellen","",0,"{ENTER}") $Sek = 1 Sleep($Sek * 500);0,5 sekunden später ControlSend("THEORG Datensicherung erstellen","",0,"{ENTER}") $Sek = 1 Sleep($Sek * 500);0,5 sekunden später ControlSend("THEORG Datensicherung erstellen","",0,"{ENTER}") $Sek = 1 Sleep($Sek * 500);0,5 sekunden später ControlSend("THEORG Datensicherung erstellen","",0,"{ENTER}") $Sek = 1 Sleep($Sek * 500);0,5 sekunden später ControlSend("THEORG Datensicherung erstellen","",0,"{ENTER}") $Sek = 1 Sleep($Sek * 15000);15 sekunden später; Die mehrstellige Zahl ändern um die länge der Datenrevision anzupassen. Beispiel: 1 m = 60s = 60000ms ControlSend("THEORG Datensicherung erstellen","",0,"{ENTER}") $Sek = 1 Sleep($Sek * 500) Run("C:\theorg\theorg\TADMIN /UNLOCKSYSTEM") ; Öffnet THEORG wieder für alle Benutzer MsgBox(64, "InfoBox", "Die Express-Datensicherung wurde erfolgreich durchgeführt.") EndFunc Func Revision() MsgBox(64, "InfoBox", "THEORG wird nun für alle Benutzer gesperrt.") Run("C:\theorg\theorg\TADMIN /SHUTDOWN=5") $Sek = 1 Sleep($Sek * 5000);5 sekunden später Run("c:\THEORG\THEORG\TADMIN.exe /REVISION") ; Startet die Datenrevision! Opt("WinWait",3) ; ; Gibt an, dass WinWait auf einen bestimmten Titel reagiert WinWait("Datenrevision und Datenbank-Update") ;Wartet mit der Durchführung der Tastenanschläge bis das Fenster "TDatenrevision und datenbank-Update" offen ist. $Sek = 1 Sleep($Sek * 500);0,5 sekunden später controlsend("Datenrevision und Datenbank-Update","",0,"{ALT down}{K}{ALT up}") $Sek = 1 Sleep($Sek * 500);0,5 sekunden später controlsend("Datenrevision und Datenbank-Update","",0,"{ENTER}") $Sek = 1 Sleep($Sek * 500);0,5 sekunden später controlsend("Datenrevision und Datenbank-Update","",0,"{ENTER}") $Sek = 1 Sleep($Sek * 500);0,5 sekunden später controlsend("Datenrevision und Datenbank-Update","",0,"{ENTER}") $Sek = 1 Sleep($Sek * 15000);15 sekunden später controlsend("Datenrevision und Datenbank-Update","",0,"{ALT down}{F}{ALT up}") $Sek = 1 Sleep($Sek * 500) controlsend("Datenrevision und Datenbank-Update","",0,"{ENTER}") $Sek = 1 Testing() EndFunc
  13. I have some updates guys, 1st of all, I seem to not have an Edit button. And 2nd I have some Problems with using the output 0 which I get when the Lines match. Here is my whole code, maybe I just made some simple mistakes. #RequireAdmin #NoTrayIcon #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <String.au3> #include <MsgBoxConstants.au3> #include <StringConstants.au3> #include <File.au3> Test() Func Test() ; Das GUI Local $hGUI = GUICreate("Test", 300, 200) ; Erstellung der Buttons Local $idRevision = GUICtrlCreateButton("Datenrevision", 30, 170, 85, 25) Local $idExpress = GUICtrlCreateButton("ExpressDasi", 120, 170, 85, 25) Local $idClose = GUICtrlCreateButton("Close", 210, 170, 85, 25) ; Darstellung des GUI GUISetState(@SW_SHOW, $hGUI) Local $iPID = 0 ; Loop bis der benutzer auf Close drückt While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $idClose ExitLoop Case $idRevision Revision() Case $idExpress Express() EndSwitch WEnd ; Delete the previous GUI and all controls. GUIDelete($hGUI) ; Close the Notepad process using the PID returned by Run. If $iPID Then ProcessClose($iPID) EndFunc Func Express() MsgBox(64, "InfoBox", "THEORG wird nun für alle Benutzer gesperrt.") Opt("WinWait",3) ; Gibt an, dass WinWait auf einen bestimmten Titel reagiert Run("C:\theorg\theorg\TADMIN /SHUTDOWN=5") ; Startet den Shutdown anderer Benutzer im THEORG und ; sperrt die Benutzung bis UNLOCK durchgeführt wird. Run("C:\THEORG\SUPPORT\BACKUP\TBSYS.EXE /SERVICE") ; WinWait("THEORG-Datensicherung") ; Wartet mit der Durchführung der Tastenanschläge bis das Fenster "THEORG-Datensicherung" offen ist. $Sek = 1 Sleep($Sek * 5000);5 sekunden später ControlSend("THEORG-Datensicherung","",0,"{ENTER}") $Sek = 1 Sleep($Sek * 500);0,5 sekunden später ControlSend("THEORG Datensicherung erstellen","",0,"{DOWN}") $Sek = 1 Sleep($Sek * 500);0,5 sekunden später ControlSend("THEORG Datensicherung erstellen","",0,"{ENTER}") $Sek = 1 Sleep($Sek * 500);0,5 sekunden später ControlSend("THEORG Datensicherung erstellen","",0,"{ENTER}") $Sek = 1 Sleep($Sek * 500);0,5 sekunden später ControlSend("THEORG Datensicherung erstellen","",0,"{ENTER}") $Sek = 1 Sleep($Sek * 500);0,5 sekunden später ControlSend("THEORG Datensicherung erstellen","",0,"{ENTER}") $Sek = 1 Sleep($Sek * 500);0,5 sekunden später ; ControlSend("Bestätigung","",0,"{RIGHT}") ; Diese zwei Tastenanschläge sorgen für die ; nicht überschreibung der zuvor $Sek = 1 ; durchgeführten Express Datensicherung. Sleep($Sek * 500);0,5 sekunden später ; ControlSend("Bestätigung","",0,"{ENTER}") ; $Sek = 1 Sleep($Sek * 500);0,5 sekunden später ControlSend("THEORG Datensicherung erstellen","",0,"{ENTER}") $Sek = 1 Sleep($Sek * 500);0,5 sekunden später ControlSend("THEORG Datensicherung erstellen","",0,"{ENTER}") $Sek = 1 Sleep($Sek * 500);0,5 sekunden später ControlSend("THEORG Datensicherung erstellen","",0,"{ENTER}") $Sek = 1 Sleep($Sek * 500);0,5 sekunden später ControlSend("THEORG Datensicherung erstellen","",0,"{ENTER}") $Sek = 1 Sleep($Sek * 500);0,5 sekunden später ControlSend("THEORG Datensicherung erstellen","",0,"{ENTER}") $Sek = 1 Sleep($Sek * 500);0,5 sekunden später ControlSend("THEORG Datensicherung erstellen","",0,"{ENTER}") $Sek = 1 Sleep($Sek * 15000);15 sekunden später; Die mehrstellige Zahl ändern um die länge der Datenrevision anzupassen. Beispiel: 1 m = 60s = 60000ms ControlSend("THEORG Datensicherung erstellen","",0,"{ENTER}") $Sek = 1 Sleep($Sek * 500) Run("C:\theorg\theorg\TADMIN /UNLOCKSYSTEM") ; Öffnet THEORG wieder für alle Benutzer MsgBox(64, "InfoBox", "Die Express-Datensicherung wurde erfolgreich durchgeführt.") EndFunc Func Revision() MsgBox(64, "InfoBox", "THEORG wird nun für alle Benutzer gesperrt.") Run("C:\theorg\theorg\TADMIN /SHUTDOWN=5") $Sek = 1 Sleep($Sek * 5000);5 sekunden später Run("c:\THEORG\THEORG\TADMIN.exe /REVISION") ; Startet die Datenrevision! Opt("WinWait",3) ; ; Gibt an, dass WinWait auf einen bestimmten Titel reagiert WinWait("Datenrevision und Datenbank-Update") ;Wartet mit der Durchführung der Tastenanschläge bis das Fenster "TDatenrevision und datenbank-Update" offen ist. $Sek = 1 Sleep($Sek * 500);0,5 sekunden später controlsend("Datenrevision und Datenbank-Update","",0,"{ALT down}{K}{ALT up}") $Sek = 1 Sleep($Sek * 500);0,5 sekunden später controlsend("Datenrevision und Datenbank-Update","",0,"{ENTER}") $Sek = 1 Sleep($Sek * 500);0,5 sekunden später controlsend("Datenrevision und Datenbank-Update","",0,"{ENTER}") $Sek = 1 Sleep($Sek * 500);0,5 sekunden später controlsend("Datenrevision und Datenbank-Update","",0,"{ENTER}") $Sek = 1 Sleep($Sek * 500);0,5 sekunden später controlsend("Datenrevision und Datenbank-Update","",0,"{ALT down}{F}{ALT up}") $Sek = 1 Sleep($Sek * 500) Local $aRetArray, $sFilePath = ("C:\THEORG\THEORG\LOGS\TADMINEvent.log") ; Pfad zur LogDatei _FileReadToArray($sFilePath, $aRetArray) Local $i = $aRetArray[0] -4 ; Position des Strings (last line - 4) Local $sStr1 = $aRetArray[$i] ; Liest die Position Local $sStr2 = FileReadLine("C:\THEORG\THEORG\LOGS\Vergleich.txt", 1) ; Pfad zum Vergleich und die Zeile 1 zum lesen ConsoleWrite("$sStr1 = " & $sStr1 & @CRLF) ; Test ConsoleWrite("$sStr2 = " & $sStr2 & @CRLF) ; Test ; wenn $iCmp = 0 dann stimmt das Ergebnis ; Vergleich der beiden Strings $iCmp = StringCompare($sStr1, $sStr2, $STR_CASESENSE) If $iCmp = 0 Then Run("C:\theorg\theorg\TADMIN /UNLOCKSYSTEM") ; Öffnet THEORG wieder für alle Benutzer MsgBox(64, "InfoBox", "Die Datenrevision wurde erfolgreich durchgeführt und das Programm ist nun wieder verwendbar") Else MsgBox(64, "InfoBox", "Die Datenrevision ist Fehlgeschlagen, bitte Fragen Sie Ihren EDV Betreuer nach Auskunft!") EndIf EndFunc Hopefully you can help me improve my script. I am really thankfull so far!
  14. Sorry, I didn't know how to edit my previous post. I Noticed my mistake $iCmp = 0 has to be the awnser. I will try and change a few things and keep you informed!
  15. Thank you very much Melba and Bill, I couldn't bring Melbas script to work but I succeded with Bills. The problem I have now is, it is written to give me the the Signal 1 if the lines match, right? ; Compare two strings with using case sensitivity. $iCmp = StringCompare($sStr1, $sStr2, $STR_CASESENSE) MsgBox($MB_SYSTEMMODAL, "", _ "Comparing '" & $sStr1 & "' To '" & $sStr2 & "'" & @CRLF & _ "StringCompare Result (mode $STR_CASESENSE): " & $iCmp) Somehow it allways tells me $iCmp = 1 I wanted to use it further on as If $iCmp = 1 Then MsgBox(64, "Infobox", "The given Lines Match", ) EndIf But if it allways tells me $iCmp ist 1 I can't really rely on that. Do you have an Idea on why it does that? I tried it multiple times and it was the same awnser.
×
×
  • Create New...