|
-
Apr 7th, 2003, 06:10 AM
#1
Thread Starter
Lively Member
Passing arguements in a Shelled program
I have noticed that my Shell function can only run a program without any arguments. I've tested it with many samples already but I can't find any which can run with arguments. How to do it? example, if i were to type in the command line... i use something like c:\.....\..\perl test.pl 2 02/03/2003 14:15:27 3 80 so, s u can c, i've got 5 arg being passed(2 ,02/03/2003 ,14:15:27, 3 ,80 ).This can work. But when I want to use the Shell function to run the program in the same manner, it doesn't. How am I to get about doing this.? pls help.
-
Apr 7th, 2003, 06:35 AM
#2
Addicted Member
how exactly are you making use of shell in your app? post a piece of the source here or just that line or something.
-=[Ç¥ßè®Ìú§]=-
How many microsoft employees does it take to change a lightbulb? None, they simply define darkness as the new industry standard.
CAUTION: OVERCLOCKING A 386 TO 5Ghz MAY BE HAZARDOUS
-
Apr 7th, 2003, 06:37 AM
#3
Lively Member
I had the same problem. My workaround:
1. Create a batch-file in the temp folder. In this batch file you can call the program with all arguments.
2. Execute the batch file.
3. Delete the batch file!
-
Apr 7th, 2003, 10:27 AM
#4
Frenzied Member
Have you considered using the ShellExecute API? I thik I have included all the pertinent code...
VB Code:
Public Const gSW_SHOWNORMAL As Integer = 1&
Public gScr_hDC As Long
Public Declare Function ShellExecute Lib "shell32.dll" _
Alias "ShellExecuteA" (ByVal hwnd As Long, _
ByVal lpszOp As String, _
ByVal lpszFile As String, _
ByVal lpszParams As String, _
ByVal lpszDir As String, _
ByVal FsShowCmd As Long) As Long
Public Declare Function GetDesktopWindow Lib "user32" () As Long
..
gScr_hDC = GetDesktopWindow()
..
Dim Result As Long
Result = ShellExecute(gScr_hDC, "Open", "some prog.exe", _
"some param list", "C:\", gSW_SHOWNORMAL)
On another note, if you want to use the previous example, you can add the "delete somebatchfile.bat" line to the batch file (as the last line to execute) and have it clean up after itself.
Last edited by ccoder; Apr 7th, 2003 at 10:31 AM.
-
Apr 7th, 2003, 11:00 AM
#5
Thread Starter
Lively Member
what else should i add in that code? Im actually want to run a perl program to create some text files. In the command line...tis is wat I do: c:\windows\desktop\....\perl CreateActivity.pl 2 20/03/2003 8 30". What i guess is, duing execution time, VB shell truncates the space aft the word "perl" so the arguments nor the perl program is executed...hope u understand what I'm saying..Thankx alot for ur help.
-
Apr 7th, 2003, 11:01 AM
#6
Thread Starter
Lively Member
what else should i add in that code? Im actually want to run a perl program to create some text files. In the command line...tis is wat I do: c:\windows\desktop\....\perl CreateActivity.pl 2 20/03/2003 8 30". What i guess is, duing execution time, VB shell truncates the space aft the word "perl" so the arguments nor the perl program is executed...hope u understand what I'm saying..Thankx alot for ur help.Note(2, 20/03/2003 ,13:15:00,8 ,30) are the 5 arguments which I need to pass in...
-
Apr 7th, 2003, 12:45 PM
#7
Frenzied Member
Hmmm. It looks like perl is the executable, CreateActivity.pl is a parameter to perl and the rest are parameters to CreateActivity.pl.
Try:
VB Code:
Result = ShellExecute(gScr_hDC, "Open", "c:\windows\desktop\....\perl CreateActivity.pl", _
"2, 20/03/2003 ,13:15:00,8 ,30", "C:\", gSW_SHOWNORMAL)
If that doesn't work, try:
VB Code:
Result = ShellExecute(gScr_hDC, "Open", "c:\windows\desktop\....\perl", _
"CreateActivity.pl 2, 20/03/2003 ,13:15:00,8 ,30", "C:\", gSW_SHOWNORMAL)
-
Apr 7th, 2003, 09:22 PM
#8
Thread Starter
Lively Member
I've tried both ways already ..No errors nor any changes..My program is supposed to create a text file based on the param passed. It works when run from command line but not in the program.. U gav the above code rite? Is tat all or do I need to add in some other codes.?I've got a sample code on this ..
PHP Code:
Dim objWSH As Object
'Do all the stuff before you call the Perl program...
'instaciate the WScript.Shell object
Set objWSH = CreateObject("WScript.Shell")
'Run the perl program, waiting for completion - execution will pause
' here until the program has completed
objWSH.Run "c:\windows\desktop\CreateAct\perl CreateActivity.pl 2 03/02/2003 13:30:00 8 30", 1, True '1 09/10/2001 13:30:00 8 30"
'clean up
Set objWSH = Nothing
'continue on with processing. When you get here the perl program will have finished.
. Can ur solution be used to fit in this ...How?Thankx for ur reply.[
Last edited by ITboy; Apr 7th, 2003 at 09:26 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|