Capture Comman Prompt without Console Window

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

User avatar
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Capture Comman Prompt without Console Window

Post by Rathinagiri »

Friends,

Anybody having simple method to capture the command prompt output? For example the below command gives me the BIOS serial number (This is required for security)

Code: Select all

wmic bios get serialnumber > sno.txt
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
andyglezl
Posts: 1461
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Contact:

Re: Capture Comman Prompt without Console Window

Post by andyglezl »

Hola Rathi

Tiene que ser por linea de comandos ?
Te serviria de esta forma ?
Pero no he visto lo del BIOS
*----------------------------------------------------
Hello Rathi

It has to be by command line?
Would you serve in this way?
But I have not seen the BIOS


Code: Select all

FUNCTION ParallelPortInfo()
	LOCAL obj, oLocator, oWmi, oCollection
	LOCAL cInfo := ""   
   
	oLocator := win_oleCreateObject( "wbemScripting.SwbemLocator" )
	oWmi     := oLocator:ConnectServer()
	cInfo := PADL( 'Paralell Port:'  , 16 ) + "  " + "No hay Puerto Paralelo Físico..." + CRLF
	oCollection:= oWMI:ExecQuery("Select * from Win32_ParallelPort")  // <======================  Win32_Bios ???
	For Each obj In oCollection
		cInfo += PADL( 'Name:'  ,      16 ) + "  " + obj:Name + CRLF
		cInfo += PADL( 'Caption:'  ,   16 ) + "  " + obj:Caption + CRLF
		cInfo += PADL( 'Description:', 16 ) + "  " + obj:Description + CRLF
		// See Properties  ---------------     http://msdn.microsoft.com/en-us/library/aa394247(v=vs.85).aspx
	Next
	cInfo += REPLICATE( "_", 77 ) + CRLF
RETURN cInfo
Andrés González López
Desde Guadalajara, Jalisco. México.
User avatar
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: Capture Comman Prompt without Console Window

Post by Rathinagiri »

Wow!

Thank you so much for the timely help @andyglezl

Code: Select all

FUNCTION GetBiosSerialNumber()
	LOCAL obj, oLocator, oWmi, oCollection
	LOCAL cInfo := ""   
   
	oLocator := win_oleCreateObject( "wbemScripting.SwbemLocator" )
	oWmi     := oLocator:ConnectServer()
	oCollection:= oWMI:ExecQuery("Select * from Win32_BIOS")  // <======================  Win32_Bios ???
	For Each obj In oCollection
		cInfo := obj:SerialNumber 
		// See Properties  ---------------     http://msdn.microsoft.com/en-us/library/aa394247(v=vs.85).aspx
	Next
RETURN cInfo
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
bpd2000
Posts: 1207
Joined: Sat Sep 10, 2011 4:07 am
Location: India

Re: Capture Comman Prompt without Console Window

Post by bpd2000 »

Another option:

Code: Select all

Function main()
local cStdOut, oplist

hb_processRun( "cmd.exe /C start /b wmic bios get serialnumber",, @cStdOut )

Msginfo( "result:" + cStdOut)
HB_MEMOWRIT("Result.txt", cStdOut)

Return nil
BPD
Convert Dream into Reality through HMG
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: Capture Comman Prompt without Console Window

Post by esgici »

Viva INTERNATIONAL HMG :D
trmpluym
Posts: 303
Joined: Tue Jul 15, 2014 6:52 pm
Location: The Netherlands

Re: Capture Comman Prompt without Console Window

Post by trmpluym »

Somebody knows a way to do the same for PowerShell ?

So launch a PowerShell script and capture the resulting output ?

Maybe a C Guru knows how, here a starting point:

https://blogs.msdn.microsoft.com/kebab/ ... ts-from-c/
User avatar
bpd2000
Posts: 1207
Joined: Sat Sep 10, 2011 4:07 am
Location: India

Re: Capture Comman Prompt without Console Window

Post by bpd2000 »

trmpluym wrote: Sun Nov 18, 2018 11:10 am Somebody knows a way to do the same for PowerShell ?

So launch a PowerShell script and capture the resulting output ?

Maybe a C Guru knows how, here a starting point:

https://blogs.msdn.microsoft.com/kebab/ ... ts-from-c/
There may be other solution:

Code: Select all

// demo using power shell 
Function main()
local cStdOut, oplist

hb_processRun( "powershell.exe -WindowStyle Hidden Get-WmiObject -Class Win32_BIOS ",, @cStdOut )

Msginfo( "result:" + cStdOut)
HB_MEMOWRIT("PS_Result.txt", cStdOut)
Return nil
BPD
Convert Dream into Reality through HMG
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: Capture Comman Prompt without Console Window

Post by esgici »

Viva INTERNATIONAL HMG :D
User avatar
dragancesu
Posts: 920
Joined: Mon Jun 24, 2013 11:53 am
DBs Used: DBF, MySQL, Oracle
Location: Subotica, Serbia

Re: Capture Comman Prompt without Console Window

Post by dragancesu »

https://www.nextofwindows.com/the-best- ... ws-machine

I need some data for security, I was try Rathi's version and result is OEM, bios serial number is OEM, I don't believe but that's it
edk
Posts: 909
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland

Re: Capture Comman Prompt without Console Window

Post by edk »

On some machines I've got "Default string" as Serial number

Code: Select all

SMBIOSBIOSVersion : F8
Manufacturer      : American Megatrends Inc.
Name              : BIOS Date: 10/30/17 14:30:15 Ver: 05.0000C
SerialNumber      : Default string
Version           : ALASKA - 1072009
Post Reply