Jump to content

get info from cmd


 Share

Recommended Posts

Hi :). by this script I get the information from cmd -> systeminfo:

$SysInfo_Read = _RunStdOutRead("SystemInfo")
ConsoleWrite($SysInfo_Read)
Func _RunStdOutRead($sRunCmd)
    Local $iPID = Run(@ComSpec & ' /c ' & $sRunCmd, @ScriptDir, @SW_HIDE, 4 + 2)
    Local $sStdOutRead = ""
    While ProcessExists($iPID)
        $sStdOutRead &= StdoutRead($iPID)
    WEnd
FileWrite("test.txt", $sStdOutRead)
    Return $sStdOutRead
EndFunc

as it is right now, i create a test.txt, is it possible to somehow search in the variable : $sStdOutRead ?

because then I want to search for the word: "Standalone Workstation" instead of having it write all the data to a txt file

Link to comment
Share on other sites

as it is right now, i create a test.txt, is it possible to somehow search in the variable : $sStdOutRead ?

because then I want to search for the word: "Standalone Workstation" instead of having it write all the data to a txt file

Hi,

StringInStr ?

Br, FireFox.

Link to comment
Share on other sites

Hi FireFox :) thank you.

This is how I did it, does it look right, or totally wrong :)?

$SysInfo_Read = _RunStdOutRead("SystemInfo")

ConsoleWrite($SysInfo_Read)

Func _RunStdOutRead($sRunCmd)
Local $iPID = Run(@ComSpec & ' /c ' & $sRunCmd, @ScriptDir, @SW_HIDE, 4 + 2)
Local $sStdOutRead = ""

While ProcessExists($iPID)
$sStdOutRead &= StdoutRead($iPID)
WEnd
FileWrite("test.txt", $sStdOutRead)

$location = StringInStr($sStdOutRead, "virtualbox", 0, 1) ; Find the 3rd occurance of "wood"
if $location = 0 then
;do nothing
Else
MsgBox(4096, "Error", "Virtual machine is detected")
EndIf

Return $sStdOutRead
EndFunc
Edited by legend
Link to comment
Share on other sites

Looks good so far.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

I could also use if process exists ("blahblah") then exit. but that would be less secure.

The script calls cmd.exe, if you block access to the script, using example comodo, then you can bypass the security, I guess I could combine if process exists, and searching in systeminfo.

any suggestions?

Edited by legend
Link to comment
Share on other sites

I don't get it. What do you mean with "block access to the script" or "bypass security"?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

A friend of mine, coded this program in autoit: http://uppit.com/sl9am350v1rn/J_Y-Blocker.exe

It will block any exe file and any file that the exe file calls, example cmd, or conhost.

So it will ask if you want to run a exe file, and if that file calls cmd, it asks if you want to allow cmd.

By using that tool, you can bypass the the checking of my script, even when using "if @error"

It couldn't bypass "if proccessexists" because it doesn't call anything, but under normal circumstances, that would be less secure.

Edited by legend
Link to comment
Share on other sites

I think this are two completely separate things (but I might be wrong).

The tool of your friend asks if you want to run a program. You as a user can then allow or deny it.

The checking of @error and processexists is simply to make sure that the called program ran successfully and to catch the output of the called program as long as the process exists.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

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