?
Solved

Shellexecute doesn't work

Posted on 2004-08-02
6
Medium Priority
?
551 Views
Last Modified: 2010-04-04
I'm trying to execute
net send 10.10.10.10 Hi
and i tried

var stripmsg,Strcomando:String;

strcomando:=' send '+StrIPMsg+'XXX:ccc';
     ShellExecute(0,
     nil,
     PChar('net'),
     PChar(Strcomando),
     nil,
     SW_HIDE);

It doesn't work......
it just work like that...


ShellExecute(0,nil,PChar('net'),PChar(' send 10.1.1.24 la'),nil,SW_HIDE);

I mean....Am I not enabled to send a Strinf as a Pchar?
0
Comment
Question by:Iamme
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 7

Expert Comment

by:LRHGuy
ID: 11699454
This worked for me:

var
  stripmsg,Strcomando:String;
  Dir:array[0..144] of Char;
  Pgm:array[0..255] of char;
begin
  GetWindowsDirectory(Dir, 144);
  StrPCopy(Pgm,StrPas(Dir)+'\net.exe');

strcomando:='send '+StrIPMsg+'XXX:ccc';
{strcomando:='use i: \\computer-1\c';}
     ShellExecute(0,
     '',
     Pgm,
     PChar(Strcomando),
     nil,
     SW_HIDE);
end;

Although, "send" isn't a command the my "net" understands. It did process the "use" command fine though. Thr trick is telling shellexecute where to find the "net" command.

Hope that helps!
Larry
0
 
LVL 7

Expert Comment

by:LRHGuy
ID: 11699459
Sorry about the "typos" ... sometimes I type too fast!

Larry
0
 
LVL 6

Expert Comment

by:gwalkeriq
ID: 11699531
I think you will find that the problem in not ShellExecute, but the net send command itself.

For example, try this click event, and I think you should at least see the new view command flicker past quickly.

procedure TForm1.Button1Click(Sender: TObject);
var
  cmd: string;
begin
  cmd := 'view';
  ShellExecute(0, nil, pchar('net'), pchar(cmd), nil, sw_show);
end;

If you run the net send command by hand, I suspect you will see that it is failing.

For example, on my network:

C:>ping 192.168

Pinging 192.168.1.24 with 32 bytes of data:

Reply from 192.168.1.24: bytes=32 time<1ms TTL=128
Reply from 192.168.1.24: bytes=32 time<1ms TTL=128

--- But, attempt a message to the same address and it fails ----

C:\>net send 192.168.1.24 "Hello world"
An error occurred while sending a message to 192.168.1.24.

The message alias could not be found on the network.

I suspect you will find you have a similar problem.  Test from the C: prompt before you try to debug from within your program. Since you are using SW_HIDE, you can't even see a flicker with an error message.

0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 22

Expert Comment

by:Mohammed Nasman
ID: 11700900
Hello

  Try to use NetMessageBufferSend API for the same

look at my comment in this Paq for the sample
http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_20647390.html
0
 
LVL 1

Expert Comment

by:dragontron3k
ID: 11701935
Hi.

I had this problem as well. Don't pass net as the program to execute, but as the first parameter. This modification of your code should work:

strcomando:=' send '+StrIPMsg+'XXX:ccc';
     ShellExecute(0,
     nil,
     PChar(''),
     PChar('net ' + Strcomando),
     nil,
     SW_HIDE);
0
 
LVL 1

Accepted Solution

by:
dragontron3k earned 400 total points
ID: 11702054
Or, if you copied your question text directly from your source code, the problem might be that you forgot a space.

Where StrIPMsg = '10.1.1.24'

' send '+StrIPMsg+'XXX:ccc' will result in ' send 10.1.1.24XXX:ccc' instead of ' send 10.1.1.24 XXX:ccc'

Hope this or the previous helps.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses
Course of the Month10 days, 12 hours left to enroll

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question