Search the Community
Showing results for tags '@ComSpec'.
-
So I am trying to write a script that can take the current computer name and write it to a registry key. This key uses REG_BINARY type of key and looks like this: Value 1 Name: LocalName Type: REG_BINARY Data: 00000000 54 4f 55 47 48 42 4f 4f - 4b 36 30 39 38 00 00 00 TOUGHBOOK6098... 00000010 00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 ................ 00000020 00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 ................ 00000030 00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 ................ 00000040 00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 ................ 00000050 00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 ................ 00000060 00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 ................ 00000070 00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 ................ 00000080 00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 ................ 00000090 00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 ................ 000000a0 00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 ................ 000000b0 00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 ................ 000000c0 00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 ................ 000000d0 00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 ................ 000000e0 00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 ................ 000000f0 00 00 00 00 00 00 00 00 - ........ Its apparently very important that all the ending 00's are in there I found this out as I was working on some other keys that had to do with security settings, and if the key was say 01 00 00 putting any less or any extra ending zeros would cause the change in the regsitry to not effect the software. So what I am attempting to do is use the @ComputerName macro and plug it into a StringtoBinary() function and then write it to the registry. The challenge I face is how to fill in the entire binary value for the registry key and not just the converted strings value. I wonder if there is some easy code to do that. I imagine there must be a few ways but I am looking for the most straight forward/easiest. Also on a side note, instead of using RegWrite is there a way to create a .REG file that I can call from CMD with Reg Import? This is being done at an enterprise level and the users do not have access to write to the registry, but they can import a reg file via .bat or in my case a Autoit .exe with @ComSpec Currently I am importing all the "static" keys I need for configuration, but computer name is dynamic so that is why I am trying to find a way to use the @ComputerName macro to insert that value. Regards,
-
I have spent the past couple of hours trying to find a solution to this. Is there a way to output the data from a RunWait to a text file? I need to use the RunWait as I need each command to complete before the next one starts. Any help would be greatly appreciated. I have tried RunWait(@ComSpec & " /c " & GUICtrlRead($hLetter) & ":&&cd\" & GUICtrlRead($hPath) & "&&TAKEOWN /f " & GUICtrlRead($hFolder) & " /r /d y" > "C:\log.txt", "", @SW_HIDE) But that does not work either. Here is my code: #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <EditConstants.au3> #include <MsgBoxConstants.au3> ;=============Main=GUI================= $hGUI = GUICreate("", 250, 500) ;====================================== ;=================Inputs=============== $hOld = GUICtrlCreateInput("", 95, 25, 130) $hNew = GUICtrlCreateInput("", 95, 50, 130) $hOldSvr1 = GUICtrlCreateInput("", 95, 75, 25) GUICtrlSetLimit(-1, 3) $hOldSvr2 = GUICtrlCreateInput("", 130, 75, 25) GUICtrlSetLimit(-1, 3) $hOldSvr3 = GUICtrlCreateInput("", 165, 75, 25) GUICtrlSetLimit(-1, 3) $hOldSvr4 = GUICtrlCreateInput("", 200, 75, 25) GUICtrlSetLimit(-1, 3) $hNewSvr1 = GUICtrlCreateInput("", 95, 100, 25) GUICtrlSetLimit(-1, 3) $hNewSvr2 = GUICtrlCreateInput("", 130, 100, 25) GUICtrlSetLimit(-1, 3) $hNewSvr3 = GUICtrlCreateInput("", 165, 100, 25) GUICtrlSetLimit(-1, 3) $hNewSvr4 = GUICtrlCreateInput("", 200, 100, 25) GUICtrlSetLimit(-1, 3) $hLetter = GUICtrlCreateInput("", 95, 125, 130) $hPath = GUICtrlCreateInput("", 95, 150, 130) $hFolder = GUICtrlCreateInput("", 95, 175, 130) $hUID = GUICtrlCreateInput("", 95, 200, 130) $hExclude = GUICtrlCreateInput("", 95, 225, 130) ;====================================== ;=================Buttons============== $hButton1 = GUICtrlCreateButton("Test", 50, 260, 50) ;====================================== ;=================Labels=============== $hLabel1 = GUICtrlCreateLabel("Old Domain", 10, 28) $hLabel2 = GUICtrlCreateLabel("New Domain", 10, 53) $hLabel3 = GUICtrlCreateLabel("Old Server (IP)", 10, 78) $hLabel4 = GUICtrlCreateLabel("New Server (IP)", 10, 103) $hLabel5 = GUICtrlCreateLabel("Drive Letter", 10, 128) $hLabel5 = GUICtrlCreateLabel("Folder Path", 10, 153) $hLabel6 = GUICtrlCreateLabel("Folder Name", 10, 178) $hLabel7 = GUICtrlCreateLabel("User Name", 10, 203) $hLabel8 = GUICtrlCreateLabel("Exclusions", 10, 228) ;====================================== GUISetState(@SW_SHOW, $hGUI) While 1 Switch GUIGetMSG() Case $GUI_EVENT_CLOSE ExitLoop Case $hButton1 _TestOnly() EndSwitch WEnd Func _TestOnly() RunWait(@ComSpec & " /k " & GUICtrlRead($hLetter) & ":&&cd\" & GUICtrlRead($hPath) & "&&TAKEOWN /f " & GUICtrlRead($hFolder) & " /r /d y") RunWait(@ComSpec & " /k " & GUICtrlRead($hLetter) & ":&&cd\" & GUICtrlRead($hPath) & "&&icacls " & GUICtrlRead($hFolder) & " /reset /T") RunWait(@ComSpec & " /k " & GUICtrlRead($hLetter) & ":&&cd\" & GUICtrlRead($hPath) & "&&icacls " & GUICtrlRead($hFolder) & "\*.* /inheritance:d /c /t") EndFunc