Jump to content

Recommended Posts

Posted

Hello guys,

iam sure I just have a logic faillure.

I "ask" the cmd to get some information. Here my code fragment:

;All fine till here

      Case $msg = $Button3

      Global $DOS1, $MessageA1 = '' ;; added "= ''" for show only.
      $DOS1 = Run(@ComSpec & " /c quser %username%", "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
      ProcessWaitClose($DOS1)
      $MessageA1 = StdoutRead($DOS1)

      Global $DOS2, $MessageA2 = '' ;; added "= ''" for show only.
      $DOS2 = Run(@ComSpec & " /c echo %username%", "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
      ProcessWaitClose($DOS2)
      $MessageA2 = StdoutRead($DOS2)

      MsgBox(0, "Stdout Read:", $MessageA2)

      MsgBox(0, "Stdout Read:", $MessageA1)
      $messageA1= StringReplace ($messageA1, "Benutzername          Sitzungsname       ID  STATUS  LEERLAUF   ANMELDEZEIT", "")
      MsgBox(0, "Stdout Read:", $MessageA1)
      $messageA1= StringReplace ($messageA1, ">", "")
     MsgBox(0, "Stdout Read:", $MessageA1)

I get a positive result for $MessageA1 - all data are good and I get a positive result for $MessageA2 regarding StdoutRead.

I can do some string operations, but then I want to do:

$messageA1= StringReplace ($messageA1, $MessageA2, "")
     MsgBox(0, "Stdout Read:", $MessageA1)

I want to reduce the String $MessageA1 with $MessageA2. But it does not work.

Could please anyone give me an idea?

2nd Question:

Has maybe somebody an good idea how to separade "Id" which just have "blank" as separator. And yes the "blanks" could be one or 10.

Thx

 

 

Posted
1 hour ago, Friedel2k said:

I want to reduce the String $MessageA1 with $MessageA2. But it does not work.

This means that StringReplace didn't find $MessageA2 in $MessageA1. One blank space only can make a difference

To remove blanks : StringStripWS, StringStripCR, StringRegExpReplace, etc

Posted

Hello mikell,

u are right! Missing element:

$MessageA2 = StringStripWS ($MessageA2, $STR_STRIPALL)

and it works. The mystery is, if I export the string to a txt or something like that - I have not seen it. Also no other char.

 

Thank u!

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...