Jump to content
Advert

cvocvo

Active Members
  • Posts

    43
  • Joined

  • Last visited

cvocvo's Achievements

Seeker

Seeker (1/7)

0

Reputation

  1. Ah, my oversight there. Thank you for the help -- works great!
  2. Thanks for the help, but those didn't work. I tested with a messagebox and got a blank messagebox for the StringRegExp and the StringRegExpReplace. I sent the output to a txt file, here's the output for fbwfmgr: File-based write filter configuration for the current session: filter state: disabled. File-based write filter configuration for the next session: filter state: enabled. overlay cache data compression state: enabled. overlay cache threshold: 256 MB. overlay cache pre-allocation: disabled. size display: actual mode. protected volume list: \Device\HarddiskVolume2 write through list of each protected volume: \Device\HarddiskVolume2: \Windows\bootstat.dat \Windows\System32\spool \Windows\Prefetch \Windows\Debug\Usermode \pagefile.sys \temp Also, here is the code I'm using to get the output from fbwfmgr: $fbwfmgr = Run(@ComSpec & " /c fbwfmgr", "", @SW_HIDE, $STDERR_MERGED) ;;getstatus While 1 $Status &= StdoutRead($fbwfmgr) If @error Then ExitLoop Wend MsgBox(0, "The output is:", $Status)
  3. I need some help with StringRegExp and StringRegExpReplace in parsing the output (STDOUT, but using $STDERR_MERGED) of fbwfmgr. Enabled Output: Disabled Output: In the enabled output picture I need to use StringRegExpReplace to replace the "Filter State: Enabled" under "next session:" with "Filter State: Disabled". In the disabled output picture I need to be able to read (into a variable) the "filter state: disabled" text that follows "current session:" and I need to read (into a variable) the "filter state: enabled" text that follows "next session:". The tricky part here is that I basically just need to read the line below current session and next session into variables, and the "filter state: " portion can be enabled or disabled for both. I've tried to accomplish this with using StringSplit with @CRLF's and it doesn't seem to split the lines up for some reason, and I've also tried to use StringInStr but that didn't work because I couldn't get it to search over multiple lines of characters for the character limit. I tried using StringRegExp with '(next session:)\s(filter state:)\s[:alnum:], but I don't understand it enough to get it to work. If there are any ninja's of StringRegExp and StringRegExpReplace out there that could help, I'd appreciate it. Thanks
  4. I am having problems getting this to run in Windows XP. I tried even using the examples and the server gets stuck (meaning the tooltip stays up) on the creating server part. Any ideas on why this might be? Needs files or needs updated or something? Edit: I was mistaken, the example client server scripts work, but mine doesn't. Looks like I need to dig in and find out. Edit 2: I went through all of my code and rewrote everything only to figure out that my server works fine. The problem is that the client isn't detecting that it got connected, but the server did. Not sure why the client isn't connecting properly in my code, but it works well enough to use.
  5. Awesome, I was having some doubt as to how my newly created service would be able to communicate with another application but this clears it up -- I thought it worked like this after I looked at it in ProcMon. Thanks
  6. I guess a slightly more specific or better question might be this scenario + question: I used your UDF to write a service that uses TCP Sockets to communicate with other things. I wrote a test application in AutoIt to send commands to the service. Your UDF uses some sort of event registering mechanism to see when messages are received or clients are connected. If I write a client to send commands to the service in a language like C#, do I have to do some sort of event registering or can I just write data to the TCP Socket and the service will listen to everything written there?
  7. Is this UDF capable of communicating via TCP Sockets with applications not written in AutoIt? More specifically, does an application not written in AutoIt (c# for example) need to do an event register before it sends data or something of the like?
  8. I am working with Named Pipes and by default when the Named Pipe is created it is set to use a default security descriptor structure. I need to know how to make a custom security descriptor (default is Global Const $tagSECURITY_ATTRIBUTES). The descriptor basically needs to let me add the Users group or atleast a specific user to have full control, like the Owner does. That way a regular user can read and write to the named pipe created by the privileged user. I know I have to use DllStructCreate to make the structure and then DllStructGetPtr to get the memory location pointer to use for the named pipe, but does anyone know HOW to make this custom security descriptor? I'd just need a simple example or a help page someplace to figure it out. Any thoughts/help? Thanks I found this good article about the SDDL (Security Description Definition Language), but I'm not sure how to apply this to use with AutoIt: http://blogs.charteris.com/blogs/chrisdi/archive/2008/06/16/exploring-the-wcf-named-pipe-binding-part-2.aspx I also found this post: http://www.autoitscript.com/forum/index.php?showtopic=115688 It's doing some run as stuff, but it has some custom security descriptor stuff in it, but I'm not sure where the actual access control list (ACL) stuff gets set, because it doesn't appear to in the example on that post. Here's the code I'm looking at from there: ;;I've commented what I think is happening below $lpProcessAttributes = DllStructCreate($tagSECURITY_ATTRIBUTES) $lpThreadAttributes = DllStructCreate($tagSECURITY_ATTRIBUTES) ;; Looks to be creating the security attributes structure $bInheritHandles = False ;; Is this setting the inherit handles flags for both security structures? $dwCreationFlags = 0x0 ;; Not sure what this is setting $lpEnvironment = "" $lpCurrentDirectory = "" DllStructSetData($lpThreadAttributes, "Descriptor", "") $ta_size = DllStructGetSize($lpThreadAttributes) DllStructSetData($lpThreadAttributes, "Length", $ta_size) DllStructSetData($lpProcessAttributes, "Descriptor", "") $pa_size = DllStructGetSize($lpProcessAttributes) DllStructSetData($lpProcessAttributes, "Length", $pa_size) Anyone have insight here?
  9. I'm tearing through the _NamedPipes_Server.au3 and _NamedPipes_Client.au3 scripts (%programfiles%\AutoIt3\Examples\GUI\Advanced\) I have the scripts working so that the client will send message that I want to the server app, the server app does a few things and generates a value to send back. I can see in the _NamedPipes_Server app that the function RelayOutput() should be doing the sending of data back to the client, but I can't quite figure out how to send my data back to the Client. Here's the RelayOutput function from the example: Func RelayOutput() Local $pBuffer, $tBuffer, $sLine, $iRead, $bSuccess, $iWritten $tBuffer = DllStructCreate("char Text[" & $BUFSIZE & "]") $pBuffer = DllStructGetPtr($tBuffer) ; Read data from console pipe _WinAPI_ReadFile($hReadPipe, $pBuffer, $BUFSIZE, $iRead) if $iRead = 0 then MsgBox(0, "server", "RelayOutput .......: Write done") _WinAPI_CloseHandle($hReadPipe) _WinAPI_FlushFileBuffers($hPipe) ReconnectClient() Return endif ; Get the data and strip out the extra carriage returns $sLine = StringLeft(DllStructGetData($tBuffer, "Text"), $iRead) $sLine = StringReplace($sLine, @CR & @CR, @CR) $iToWrite = StringLen($sLine) DllStructSetData($tBuffer, "Text", $sLine) ; Relay the data back to the client $bSuccess = _WinAPI_WriteFile($hPipe, $pBuffer, $iToWrite, $iWritten, $pOverlap) if $bSuccess and ($iWritten = $iToWrite) then MsgBox(0, "server", "RelayOutput .......: Write success") else if not $bSuccess and (@Error = $ERROR_IO_PENDING) then MsgBox(0, "server", "RelayOutput .......: Write pending") $iState = 2 else ; An error occurred, disconnect from the client MsgBox(0, "server", "RelayOutput .......: Write failed") ReconnectClient() endif endif EndFunc The data I want to send back is less than 10 characters and contained in the global variable $sMessage. How can I edit the above function to send my $sMessage to the client? My second question is how can I verify the data got to the client? I'd like to throw a message box from the client application with the received data in it. The client application reads data with the ReadMsg function, but I'm not sure which variable contains the data (I've tried most of them in the ReadMsg() function.) Func ReadMsg() Local $bSuccess, $iRead, $pBuffer, $tBuffer $tBuffer = DllStructCreate("char Text[4096]") $pBuffer = DllStructGetPtr($tBuffer) While 1 $bSuccess = _WinAPI_ReadFile($hPipe, $pBuffer, $BUFSIZE, $iRead, 0) If $iRead = 0 Then ExitLoop If Not $bSuccess Or (@error = $ERROR_MORE_DATA) Then ExitLoop WEnd MsgBox(0, "Client", "info: " & $hPipe & $pBuffer & $BUFSIZE & $iRead & $tBuffer) EndFunc ;==>ReadMsg I don't think this should be too difficult, but I'm not familiar enough with the different commands and structures used in the code. Any thoughts? Thanks Edit: After starting from the beginning again I figured out how everything is supposed to work. Here's what I got working on those two functions: Server RelayOutput: ($sMessage is a globally defined variable, and the data you want to send to the client. Local $pBuffer, $tBuffer, $sLine, $iRead, $bSuccess, $iWritten ;Create the Structure for carrying data $tBuffer = DllStructCreate("char Text[" & $BUFSIZE & "]") ;Get the memory pointer (location) of the structure $pBuffer = DllStructGetPtr($tBuffer) ;Set the number of number of characters of data to be sent $iToWrite = StringLen($sMessage) + 1 ;Write the $sMessage (data to send back) to the $tBuffer variable DllStructSetData($tBuffer, "Text", $sMessage) ;MsgBox(0, "Server", StringLeft(DllStructGetData($tBuffer, "Text"), $iToWrite)) ;Messagebox to show what is being sent ;Send Data back to client $bSuccess = _WinAPI_WriteFile($hPipe, $pBuffer, $iToWrite, $iWritten, $pOverlap) if $bSuccess and ($iWritten = $iToWrite) then ;MsgBox(0, "NamedPipes_Server", "RelayOutput .......: Write success") _WinAPI_CloseHandle($hPipe) $iState = 0 else if not $bSuccess and (@Error = $ERROR_IO_PENDING) then ;MsgBox(0, "NamedPipes_Server", "RelayOutput .......: Write pending") $iState = 2 else ; An error occurred, disconnect from the client ;MsgBox(0, "NamedPipes_Server", "RelayOutput .......: Write failed") ReconnectClient() endif endif InitPipe() EndFunc ;==>RelayOutput Client ReadMsg: Func ReadMsg() Local $bSuccess, $iRead, $pBuffer, $tBuffer $tBuffer = DllStructCreate("char Text[4096]") $pBuffer = DllStructGetPtr($tBuffer) While 1 $bSuccess = _WinAPI_ReadFile($hPipe, $pBuffer, $BUFSIZE, $iRead, 0) If $iRead = 0 Then ExitLoop If Not $bSuccess Or (@error = $ERROR_MORE_DATA) Then ExitLoop WEnd MsgBox(0, "Client", DllStructGetData($tBuffer, "Text")) ;;This displays what is relayed back to the client application. EndFunc ;==>ReadMsg
  10. I've written a service in AutoIt using the _Service UDF:http://www.autoitscript.com/forum/index.php?showtopic=80201&st=0 Now what I want to do is send a custom command from a C# app to the AutoIt service. It's shown how this is done in a C# service here: http://arcanecode.com/2007/05/30/windows-services-in-c-sending-commands-to-your-windows-service-part-7/ But does anyone know how that might be accomplished for the AutoIt service or IF it can be done? Thanks
  11. So I've tried two implementations to get my service application to recognize a STOP when it's sent. Basically I've plugged my application into the main_init() function from the 2nd example and my application basically runs a loop to check the status of a file and writes it to a memory location. When I use either of the implementations to detect a stop, it causes my application to not even get to the point where it checks file status. I've tried making my loop in the main_init() function like these: Implementation 1 Do If _WinAPI_WaitForSingleObject($service_stop_event, 0) Then $forever = 1 ExitLoop ;;goes back to _Svc_Main() Else ;;my app is here EndIf Until $forever = 1 Implementation 2 Do $Status = _Service_QueryStatus($sServiceName) If $Status[1] = $SERVICE_STOP_PENDING Then $forever = 1 ExitLoop ;;goes back to _Svc_Main() Else ;;my app is here EndIf Until $forever = 1 Any ideas why this may not be working or how I should be detecting a stop sent to the service?
  12. One way to do it would be to get use some of the Process UDF's from around the forum to get the user that is currently running explorer. Once you have that then you can substitute that value in instead of %username% and use runas. I can't remember which UDF you want to use, but basically it parses the running processes and then you could do some string matching and get the username. I think I might have written something that even uses this, but I can't seem to find it.
  13. I've been looking for a clean way to get the current path of a explorer window in Windows 7/Vista and have yet to come across anything. What I have found is a stellar solution for Windows XP: http://www.autoitscript.com/forum/index.php?showtopic=89833 Has anyone succeeded in getting this (above) script to work in Windows Vista or 7? I don't understand why it wouldn't work in 7 -- the class for an explorer window is still CabinetWClass. Any suggestions that might help get this working? Or any other solutions that might solve this problem?--I could always use @OSVersion and fork for XP and Vista/7. Thanks Edit: After thinking about this some more, I have something that will work. *Note: I haven't tested on Vista yet, only 7. ;;;This is the code that would go in your code, does the string analysis to get the path for $i = 1 to $var[0][0] If @OSVersion = "WIN_7" Then $string = _GetWindowsExplorerPath($var[$i][1]) $string = StringReplace($string, "Address: ", "") $string = StringSplit($string, @CRLF) MsgBox(0,"", $string[1]) ElseIf @OSVersion = "WIN_VISTA" Then $string = _GetWindowsExplorerPath($var[$i][1]) $string = StringReplace($string, "Address: ", "") $string = StringSplit($string, @CRLF) MsgBox(0,"", $string[1]) Else MsgBox (0, "", _GetWindowsExplorerPath($var[$i][1])) EndIf Next ;;This gets added to the function ;;It goes below this line: ;;If ($className[2] <> "ExploreWClass" And $className[2] <> "CabinetWClass") Then Return SetError(1, 0, "") If @OSVersion = "WIN_7" Then Return WinGetText($hWnd,"") If @OSVersion = "WIN_Vista" Then Return WinGetText($hWnd,"") Hopefully there's a less messy solution out there, but for now this seems like it could work.
  14. From what I've read on the forums here it's only disabled for my application and there isn't any need to switch it back. If this isn't the case, how would I switch it back on? Edit: I want to use this so it uses the 64bit versions of regedit and cmd. I'm doing some reg exporting, batch file creation, and some other stuff that makes 64bit versions of those way easier to work with.
  15. I am running a 32bit app on 64bit machines sometimes, when I disable filesystem redirection, @ProgramFilesDir still shows C:\Program Files (x86). Is there any way to update the @ProgramFilesDir to point at the location %programfiles% reflects once filesystem redirection is disabled? Thanks Edit: I couldn't figure out how to get the variables to update, but I wrote a work around: If @OSArch = "X64" Then DllCall("kernel32.dll", "int", "Wow64DisableWow64FsRedirection", "int", 1) ;;Disables file system redirection for 32bit apps in 64bit land $ProgramFiles = @ProgramFilesDir $ProgramFiles = StringReplace($ProgramFiles, " (x86)", "") Else $ProgramFiles = @ProgramFilesDir EndIf MsgBox(0,"", $ProgramFiles)
×
×
  • Create New...