-
Posts
7 -
Joined
-
Last visited
Profile Information
-
Location
Chicago
OMGWTFLOLBBQ's Achievements

Seeker (1/7)
0
Reputation
-
Hello Everyone! I'm attempting to put together a code that reports select system information, and I'd like the name to include the current date/time both on the name of the file and inside. This code that I've put together puts the date and time in the text, then adds system info, but when it adds the system info, it puts spaces between everything. See below: $act = WinActivate("Administrator: C:\Windows\System32\CMD.exe") ;refocus command prompt ;BEGIN MODEL & SERIAL RETRIEVL Sleep(500) ;sleep half second if ProcessExists("cmd.exe") Then $act ;refocus command prompt ;retrieve current time Send("echo Date: %date:~4% Time: %time:~0,2%:%time:~3,2%PST >> " & Chr(34) & "%USERPROFILE%\Desktop\%COMPUTERNAME%.txt" & Chr(34) & "{Enter}") Sleep(250) ;sleep quarter second(.25s) ;retrieve model number Send("WMIC ComputerSystem get model,name,manufacturer,systemtype >> " & Chr(34) & "%USERPROFILE%\Desktop\%COMPUTERNAME%.txt" & Chr(34) & "{Enter}") Sleep(250) ;sleep quarter second(.25s) ;retrieve serial number Send("WMIC bios get serialnumber >> " & Chr(34) & "%USERPROFILE%\Desktop\%COMPUTERNAME%.txt" & Chr(34) & "{Enter}") Sleep(250) ;sleep quarter second(.25s) Send("XCopy " & Chr(34) & "%USERPROFILE%\Desktop\%COMPUTERNAME%.txt" & Chr(34) & " " & Chr(34) & "\\ServerLocation\ComputerIDs\" & Chr(34) & "{Enter}") Sleep(250) ;sleep quarter second(.25s) ;Send("ren %COMPUTERNAME%.txt %COMPUTERNAME%-%Date:~4%.txt{Enter}") Send("TaskKill /F /FI " & Chr(34) & "IMAGENAME eq cmd*" & Chr(34) & "{Enter}") EndIf Results show this(edited), date and time on one line, other info on second line. If the file is opened, and you press enter after the group of spaces after "SystemType" and then do the same thing after "x64-based PC" then everything is lined up, just spaced. Date: 07/22/2016 Time: 13:47PST M a n u f a c t u r e r M o d e l N a m e S y s t e m T y p e 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 - 0 x 6 4 - b a s e d P C S e r i a l N u m b e r 0 0 0 0 0 0 0 0 Ideally it would look like this: Date: 07/22/2016 Time: 13:47PST Manufacturer Model Name SystemType 000000 000000000 000000-000-0 x64-based PC SerialNumber 000000000 Second part is the filename...probably a dos thing. I'm trying to add just the current date to the file, like "computername-date.txt" When the line below runs, I receive the message "The system cannot find the file specified." even though it's still on the desktop. Send("ren %COMPUTERNAME%.txt %COMPUTERNAME%-%Date:~4%.txt{Enter}") In the end, I'd love a file that had all info, without the spaces, renamed on the server with the computer name and date. Also, I found if I add the date in after the system info inside the file, it shows up in kanji(I think?) characters like this "慄整›㜰㈯⼲〲㘱吠浩㩥ㄠ㨴㘱卐⁔" So, aside from writing out the commands too long, what else am I doing wrong and how can I fix it? Thanks ahead for any suggestions.
-
OMGWTFLOLBBQ reacted to a post in a topic: Text to Array
-
Edited the whole bit... see below. ;BitlockerUpdate ;2016.05.25 #include <AutoItConstants.au3> #include <Array.au3> #include <File.au3> ;definitions Local $pro = @DesktopDir & "\Protectors.txt" ;"%userprofile%\Desktop\protectors.txt" operating txt directory Local $act = WinActivate("Administrator: C:\Windows\System32\CMD.exe") ;refocus command prompt Local $bde = "manage-bde.exe{SPACE}" Local $arr = FileReadToArray($pro) Local $inf ;open command and enter proper directory for use Run("C:\Windows\System32\CMD.exe") ;open command prompt Sleep(250) ;sleep quarter second if ProcessExists("cmd.exe") Then $act ;refocus command prompt Send("C:" & "{ENTER}") ;send code "c:" then press enter Send("CD{SPACE}%windir%\sysnative\" & "{ENTER}") ;send code "CD %windir%\sysnative\" then press enter Send($bde & "-protectors{SPACE}-get{space}c:{space}>{Space}" & $pro & "{ENTER}") ;create protectors.txt on current desktop ;Sleep(250) ;sleep quarter second(.25s) EndIf ;Needs Work For $i = 0 To UBound($arr) If StringInStr($arr, "Numerical Password:") Then $inf = $arr[$i + 1] Next ;update data if ProcessExists("cmd.exe") Then winactivate("Administrator: C:\Windows\System32\CMD.exe") ;refocus command prompt Send($bde & "-protectors{SPACE}-adbackup{SPACE}c:{SPACE}") Send($inf & "{ENTER}") ;don't forget to delete temp file if you create one created. EndIf ;remove files if ProcessExists("cmd.exe") Then winactivate("Administrator: C:\Windows\System32\CMD.exe") ;refocus command prompt Send("DEL{SPACE}" & $pro & "{ENTER}") ;delete protectors.txt from current desktop EndIf ;completed & confirm message box MsgBox(0,"Done","Copy and upload are done. Please check Computer in AD.") When I run the code, no errors appear...but nothing is pasted in after the " Send($inf & "{Enter}") " code is applied after collecting the info from the array. Please see the attached image. The line that should appear is: manage-bde.exe -protectors -adbackup c: -ID {1000000-1000-1000-1000-1000000} {1000000-1000-1000-1000-1000000} is the variable though, it should be pulling the information from within protectors.txt from that line. I appreciate what you've assisted me with creating. Is it possible to get a simple definition of what you've done?
-
Thanks for the suggestions! Definitely got a few gears running. As for the first, I attempted ShellExecute, but it kept giving an error about "windows cannot find "manage-bde.exe". I know it's messy, but it seems to work...for now. After I get this working, I'll definitely work on streamlining it for the future. Second, I've edited code based off of what you've suggested. $sFile = "%userprofile%\Desktop\protectors.txt" $aFile = FileReadToArray($sFile) For $i = 0 To UBound($aFile) If StringInStr($aFile[$i], "Numerical Password:") Then _ArrayToClip($MB_OK, "", $aFile[$i + 1]) Next if ProcessExists("cmd.exe") Then winactivate("Administrator: C:\Windows\System32\CMD.exe") ;refocus command prompt EndIf ;update data if ProcessExists("cmd.exe") Then winactivate("Administrator: C:\Windows\System32\CMD.exe") ;refocus command prompt Send("manage-bde.exe{SPACE}-protectors{SPACE}-adbackup{SPACE}c:{SPACE}") Send("^v") Send("{ENTER}") ;don't forget to delete temp file if you create one created. EndIf I put that right in the middle, thinking I could skip the message box(which does appear to be showing the correct data), but nothing is pasting in with the Send("^V") command.... I appreciate the suggestions and I'll think this through for a bit tonight.
-
Apologies for the mistake, I'll be more careful in the future.
-
Hello! I've been going through all of the help files and examples, but I feel lost. I can't seem to find what I need. Essentially, what I'm doing is simple(in my head). Create a file based on the information needed, select a line in that file, then put that line back in DOS. My code is below, I know it's messy, but I'll take the heat if you can help. ;BitlockerUpdate ;2016.05.24 HotKeySet("{ESC}", "Terminate") Run("C:\Windows\System32\CMD.exe") ;open command prompt Sleep(500) ;sleep half second if ProcessExists("cmd.exe") Then winactivate("Administrator: C:\Windows\System32\CMD.exe") ;refocus command prompt Send("C:") Send("{ENTER}") send("CD{SPACE}%windir%\sysnative\") send("{ENTER}") EndIf ;create file with Bitlocker Protectors Send("manage-bde.exe{SPACE}-protectors{SPACE}-get{space}c:{space}>{Space}%userprofile%\Desktop\protectors.txt") ;send code "manage-bde -protectors -get c: > %userprofile%\Desktop\protectors.txt" Send("{ENTER}") ;send enter key to create text file on desktop with protectors Sleep(1000) ;sleep one second(1s) ;edit txt file/create array, pull line and paste into new file, copy text then paste into cmd window below ;update data if ProcessExists("cmd.exe") Then winactivate("Administrator: C:\Windows\System32\CMD.exe") ;refocus command prompt Send("manage-bde.exe{SPACE}-protectors{SPACE}-adbackup{SPACE}c:{SPACE}-id{SPACE}{COPIEDINFORMATIONGOESHERE}") Send("{ENTER}") ;don't forget to delete temp file if you create one created. EndIf ;remove files if ProcessExists("cmd.exe") Then winactivate("Administrator: C:\Windows\System32\CMD.exe") ;refocus command prompt Send("DEL{SPACE}%userprofile%\Desktop\protectors.txt") ;send code to delete protectors.txt Send("{ENTER}") ;don't forget to delete temp file if you create one created. EndIf MsgBox(0,"Done","Copy and upload are done. Please check Computer in AD.") Func Terminate() Exit 0 EndFunc The protectors.txt file looks like this: BitLocker Drive Encryption: Configuration Tool version 6.1.7601 Copyright (C) Microsoft Corporation. All rights reserved. Volume C: [OSDisk] All Key Protectors TPM: ID: {0000000-0000-0000-0000-0000000} Numerical Password: ID: {1000000-1000-1000-1000-1000000} Password: 000000-000000-000000-000000-000000-000000-000000 Data Recovery Agent (Certificate Based): ID: {2000000-2000-2000-2000-2000000} Certificate Thumbprint: 1111111a1aa1a1aa1a1a1a1aaaaaa1aaa1 I would specifically need the line after Numerical Password. Original line: ID: {1000000-1000-1000-1000-1000000} Needed information: -ID: {1000000-1000-1000-1000-1000000} I apologize in advance for inconveniencing anyone with my silly issues. Hopefully this can stand as a great learning experience for both me and anyone else looking.
-
Thanks to everyone! I appreciate all of the help. I knew it was something that I was overlooking(or overlapping). All is right with the world now.
-
Okay, I've looked all over. I know the answer is probably just on the next page. But just like the code, I know it's better to have someone else look it over sometimes. Maybe in the future if someone is attempting this they will appreciate the example. The problem is this: I've created a simple GUI with three buttons. One button launches an app then has said app go to the next screen. Second button does basically the same thing, but with Windows update. Third button just closes the box. Those all work fine. When I uncomment line 12 (Local $MsgM = GUICtrlCreateLabel("Application has completed all tasks. Please consider the following options.", 15, 35, 255, 150, $SS_CENTER)) All of the buttons cease to work. It works fine without the text(as it is below) I know there's probably a different way for me to add the text but for some reason I can't find it. ;App #include <GUIConstantsEx.au3> #include <StaticConstants.au3> App() Func App() ; Create a GUI with various controls. Local $hGUI = GUICreate("Application done!", 275, 150) ; Create a horizontally centered text label for the inside of the GUI. ; Local $MsgM = GUICtrlCreateLabel("Application has completed all tasks. Please consider the following options.", 15, 35, 255, 150, $SS_CENTER) ; Create a button control. ; Button Positioning(Horizontal from left, Vertical from top, Button Width, Button Height) Local $idLSU= GUICtrlCreateButton("Lenovo System Update", 5, 110, 130, 25) Local $idWUpdate = GUICtrlCreateButton("Windows Update", 140, 110, 130, 25) Local $idClose = GUICtrlCreateButton("Close", 121, 135, 32, 15) ; Display the GUI. GUISetState(@SW_SHOW, $hGUI) Local $iPID = 0 ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $idClose ExitLoop Case $idLSU ; Run Lenovo System Utilty. $iPID = Run("C:\Program Files (x86)\Lenovo\System Update\TVSU.exe") WinWaitActive("System Update") ;Wait for it to be active before sending commands. Send("{Enter}") ;press next on LSU main screen. Case $GUI_EVENT_CLOSE, $idClose ExitLoop Case $idWUpdate ; Run Windows Update "Run("%windir%\system32\wuapp.exe startmenu")" $iPID = Run("wuapp.exe startmenu") WinWaitActive("Windows Update") ;Wait for it to be active before sending commands. Send("{Tab}{Tab}{Tab}{Tab}{Tab}{Tab}{Tab}{Tab}{Enter}") ;Navigate to update link, then begin update check. EndSwitch WEnd ; Delete the previous GUI and all controls. GUIDelete($hGUI) ; Close the window process using the PID returned by Run. If $iPID Then ProcessClose($iPID) EndFunc ;App Any insight, help or direction pointing would be greatly appreciated. I wouldn't have been able to get to this point without these boards.