Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

ShellExecute

Posted on 2001-09-10
11
Medium Priority
?
884 Views
Last Modified: 2010-04-06
Need help with this.

I use ShellExecute to start a .bat file and want to pass variable to it.
Variables is given from dos when I start the program.
It look like this.
ShellExecute(I, 'open', 'c:\command.com', PChar('/c  s:\public\homch2.bat '+ ParamStr(1) + ParamStr(2)), nil,  sw_hide);

In the bat file it look like this.
renobj %1 %2

Is it the wrong way or wath ????
0
Comment
Question by:Dark_King
[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
  • 4
  • 3
  • 2
  • +1
11 Comments
 
LVL 13

Expert Comment

by:Epsylon
ID: 6470681
Try

ShellExecute(I, 'open', PChar('s:\public\homch2.bat '+ ParamStr(1) + ParamStr(2)), , ''
nil,  sw_hide);
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 6470687
Or with '' instead of nil

ShellExecute(I, 'open', PChar('s:\public\homch2.bat '+ ParamStr(1) + ParamStr(2)), , '' , '', sw_hide);
0
 
LVL 6

Author Comment

by:Dark_King
ID: 6470739
[Error] chechd.dpr(35): Expression expected but ',' found

Some thing is wrong here in your examples Epsylon
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 6

Author Comment

by:Dark_King
ID: 6470755
And a thing it while give me incompatible types 'Integer' and 'PChar'
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6470768
hi eps :-)
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6470793
try this

ShellExecute(I, 'open', PChar('s:\public\homch2.bat '+ ParamStr(1) + ' ' + ParamStr(2)), '' , '', sw_hide);
0
 
LVL 6

Author Comment

by:Dark_King
ID: 6470861
I found this, how do I use the lpParameters in my example.


HINSTANCE ShellExecute(

    HWND hwnd,     // handle to parent window
    LPCTSTR lpOperation,     // pointer to string that specifies operation to perform
    LPCTSTR lpFile,     // pointer to filename or folder name string
    LPCTSTR lpParameters,     // pointer to string that specifies executable-file parameters
    LPCTSTR lpDirectory,     // pointer to string that specifies default directory
    INT nShowCmd      // whether file is shown when opened
   );

lpFile

Pointer to a null-terminated string that specifies the file to open or print or the folder to open or explore. The function can open an executable file or a document file. The function can print a document file.

lpParameters

If lpFile specifies an executable file, lpParameters is a pointer to a null-terminated string that specifies parameters to be passed to the application.
If lpFile specifies a document file, lpParameters should be NULL.
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 6471147
Hi meikl   (o:

Dark King, also make sure that you use double quotes ("), when command and/or parameters contain spaces.

ShellExecute(I, 'open', PChar('"s:\public\homch2.bat" "'+ ParamStr(1)+'" "'+ParamStr(2))+'"', '' , '', sw_hide);

In most cases I leave lpParameters and lpDirectory empty (='').
0
 
LVL 5

Accepted Solution

by:
alanwhincup earned 800 total points
ID: 6471588
Try this:

ShellExecute(I, 'Open', PChar('s:\public\homch2.bat'), PChar(ParamStr(1) + ' ' + ParamStr(2)), '', SW_HIDE);

I havent tested it but it should work.
0
 
LVL 5

Expert Comment

by:alanwhincup
ID: 6471599
If that doesnt work then try:

ShellExecute(I, 'Open', PChar('s:\public\homch2.bat'), PChar(ParamStr(1) + ParamStr(2)), '', SW_HIDE);
0
 
LVL 6

Author Comment

by:Dark_King
ID: 6473350
I try all of your examples and it was close "EPS"  but one work right a way and earn the point.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone 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 The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
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…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

705 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