Jump to content
Sign in to follow this  
legend

get info from cmd

Recommended Posts

legend

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

Share this post


Link to post
Share on other sites
FireFox

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.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
legend

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

Share this post


Link to post
Share on other sites
water

Looks good so far.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
legend

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

Share this post


Link to post
Share on other sites
water

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 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
legend

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

Share this post


Link to post
Share on other sites
water

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 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
legend

that's right :) but the tool bypasses the checking

Share this post


Link to post
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
Sign in to follow this  

×