Page 1 of 1
Using hb_run inside a prg made with mod_harbour
Posted: Sun Jun 14, 2020 11:13 am
by Massimo Linossi
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
Re: Using hb_run inside a prg made with mod_harbour
Posted: Sun Jun 14, 2020 12:29 pm
by Antonio Linares
Massimo,
What is the contents of client.ps1 ?
Re: Using hb_run inside a prg made with mod_harbour
Posted: Sun Jun 14, 2020 2:59 pm
by Massimo Linossi
Code: Select all
$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
Re: Using hb_run inside a prg made with mod_harbour (solved)
Posted: Sun Jun 14, 2020 4:48 pm
by Massimo Linossi
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
Re: Using hb_run inside a prg made with mod_harbour
Posted: Sun Jun 14, 2020 5:20 pm
by Antonio Linares
Great!
Good job