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
Using hb_run inside a prg made with mod_harbour
- Massimo Linossi
- Posts: 474
- Joined: Mon Oct 17, 2005 10:38 am
- Location: Italy
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: Using hb_run inside a prg made with mod_harbour
Massimo,
What is the contents of client.ps1 ?
What is the contents of client.ps1 ?
- Massimo Linossi
- Posts: 474
- Joined: Mon Oct 17, 2005 10:38 am
- Location: Italy
Re: Using hb_run inside a prg made with mod_harbour
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
- Massimo Linossi
- Posts: 474
- Joined: Mon Oct 17, 2005 10:38 am
- Location: Italy
Re: Using hb_run inside a prg made with mod_harbour (solved)
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
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
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: Using hb_run inside a prg made with mod_harbour
Great!
Good job
Good job