FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index mod_harbour Using hb_run inside a prg made with mod_harbour
Posts: 512
Joined: Mon Oct 17, 2005 10:38 AM
Using hb_run inside a prg made with mod_harbour
Posted: Sun Jun 14, 2020 11:13 AM

Hi.
I'm trying to use the hb_run function in mod_harbour.
If I make hb_run("c:/windows/notepad.exe") works perfectly.
If I try to make the same with a bat nothing happens. I've tried with hb_run("lancio.bat"), hb_run("./lancio.bat") and hb_run("cmd lancio.bat").
The bat contains Powershell.exe -executionpolicy remotesigned -File .\client.ps1
If I launch the bat from commandline works without problems.
Is there another way to launch a bat or a ps1 file ?
Thanks a lot.
Massimo

Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Using hb_run inside a prg made with mod_harbour
Posted: Sun Jun 14, 2020 12:29 PM

Massimo,

What is the contents of client.ps1 ?

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 512
Joined: Mon Oct 17, 2005 10:38 AM
Re: Using hb_run inside a prg made with mod_harbour
Posted: Sun Jun 14, 2020 02:59 PM
Code (fw): Select all Collapse
$Port = 3030  
$IP = "192.168.10.203"   
$Message = "Message_test"

$Address = [system.net.IPAddress]::Parse( $IP )  
  
# Create IP Endpoint   
$End = New-Object System.Net.IPEndPoint $address , $port   
  
# Create Socket   
$Saddrf    = [System.Net.Sockets.AddressFamily]::InterNetwork  
$Stype    = [System.Net.Sockets.SocketType]::Dgram  
$Ptype     = [System.Net.Sockets.ProtocolType]::UDP  
$Sock      = New-Object System.Net.Sockets.Socket $saddrf , $stype , $ptype   
$Sock.TTL = 26  
  
# Connect to socket   
$sock.Connect( $end )  
  
# Create encoded buffer   
$Enc      = [System.Text.Encoding]::ASCII  
$Buffer   = $Enc.GetBytes( $Message )  
  
# Send the buffer   
$Sent   = $Sock.Send( $Buffer )  
"{0} characters sent to: {1} " -f $Sent , $IP   
"Message is:"   
$Message   
# End of Script
Posts: 512
Joined: Mon Oct 17, 2005 10:38 AM
Re: Using hb_run inside a prg made with mod_harbour (solved)
Posted: Sun Jun 14, 2020 04:48 PM

Hi Antonio.
After a lot of tests I found another way for sending a command to a computer placed on a lan.
I made a powershell program that runs on the server and waits for a broadcast message.
Then i made a ajax prg for mod_harbour that write a params file with ip, port and message to send.
With a little compiled script, I read this file and send the string to the server. This compile
script is launched from mod_harbour with hb_run function. I didn't find a way for launching it
directly or placed inside a bat.
But in this way everything works perfectly and really fast.
Thanks a lot for your time.
Massimo

Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Using hb_run inside a prg made with mod_harbour
Posted: Sun Jun 14, 2020 05:20 PM

Great! :-)

Good job

regards, saludos

Antonio Linares
www.fivetechsoft.com

Continue the discussion