Solved

Shellexecute doesn't work

Posted on 2004-08-02
6
539 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
6 Comments
 
LVL 7

Expert Comment

by:LRHGuy
Comment Utility
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
Comment Utility
Sorry about the "typos" ... sometimes I type too fast!

Larry
0
 
LVL 6

Expert Comment

by:gwalkeriq
Comment Utility
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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 22

Expert Comment

by:mnasman
Comment Utility
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
Comment Utility
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 100 total points
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
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…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

743 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now