Using hb_run inside a prg made with mod_harbour

mod_harbour is an Apache module that allows to run PRGs directly on the web !!!

Using hb_run inside a prg made with mod_harbour

Postby Massimo Linossi » 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
User avatar
Massimo Linossi
 
Posts: 498
Joined: Mon Oct 17, 2005 10:38 am
Location: Italy

Re: Using hb_run inside a prg made with mod_harbour

Postby Antonio Linares » Sun Jun 14, 2020 12:29 pm

Massimo,

What is the contents of client.ps1 ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Using hb_run inside a prg made with mod_harbour

Postby Massimo Linossi » Sun Jun 14, 2020 2:59 pm

Code: Select all  Expand view


$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

 
User avatar
Massimo Linossi
 
Posts: 498
Joined: Mon Oct 17, 2005 10:38 am
Location: Italy

Re: Using hb_run inside a prg made with mod_harbour (solved)

Postby Massimo Linossi » Sun Jun 14, 2020 4: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
User avatar
Massimo Linossi
 
Posts: 498
Joined: Mon Oct 17, 2005 10:38 am
Location: Italy

Re: Using hb_run inside a prg made with mod_harbour

Postby Antonio Linares » Sun Jun 14, 2020 5:20 pm

Great! :-)

Good job
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain


Return to mod_harbour

Who is online

Users browsing this forum: No registered users and 6 guests