Shell Function on NT 4.0 Platform 
Author Message
 Shell Function on NT 4.0 Platform



Quote:
>Yes I have the same problem,
>I want to execute a Java program and pass the user from system.environment
>to my VB but shell command send me a number.
>If you find it out let me know.
>Thanks
>Max


>>    I have a problem running a Shell routine that call a Dos BAT file on
>>NT4.0 using VB 6.0. I have incorporated this routine in a Class module and
>>built it into a DLL. The problem is that when I run the Shell command it
>>returns a Process ID but doesn't execute the batch command on NT 4.0. It
>>Works on 95/98 and the development machine which is NT 4.0. Is there
>>somthing I can change in the Deployment Wizard? Has any one had any
>problems
>>like this one.   Here is the code....

>>  Dim ProcessID As Long
>>   Dim PID As Long
>>   Dim hProcess As Long
>>   Dim hWndJob As Long
>>   Dim nRet As Long
>>   Dim TitleTmp As String
>>   Const fdwAccess = PROCESS_QUERY_INFORMATION

>>   If IsMissing(ExecMode) Then
>>      ExecMode = vbMinimizedNoFocus
>>   Else
>>      If ExecMode < vbHide Or ExecMode > vbMinimizedNoFocus Then
>>         ExecMode = vbMinimizedNoFocus
>>      End If
>>   End If

>>   On Error Resume Next
>>      ProcessID = Shell(JobToDo, CLng(ExecMode))        '    JobtoDo is a
>>.Bat File
>>      If Err Then
>>         ShellAndClose = vbObjectError + Err.Number
>>         Exit Function
>>      End If
>>   On Error GoTo 0

>>   hWndJob = FindWindow(vbNullString, vbNullString)
>>'    If hWndJob = 0 Then MsgBox " Skipping LooP"
>>   Do Until hWndJob = 0
>>      If GetParent(hWndJob) = 0 Then
>>         Call GetWindowThreadProcessId(hWndJob, PID)
>>         If PID = ProcessID Then Exit Do
>>      End If
>>      hWndJob = GetWindow(hWndJob, GW_HWNDNEXT)
>>   Loop

>>   hProcess = OpenProcess(fdwAccess, False, ProcessID)
>>   Do   TitleTmp = Space(256)
>>      nRet = GetWindowText(hWndJob, TitleTmp, Len(TitleTmp))
>>      If nRet Then
>>         TitleTmp = UCase(Left(TitleTmp, nRet))
>>         If InStr(TitleTmp, "FINISHED") = 1 Then
>>            Call SendMessage(hWndJob, WM_CLOSE, 0, 0)
>>         End If
>>      End If
>>      GetExitCodeProcess hProcess, nRet
>>      DoEvents
>>      Sleep 100
>>   Loop While nRet = STILL_ACTIVE
>>   Call CloseHandle(hProcess)

>>Thank You
>>        Tom

Look into the ShellExecute function and use it.  The shell function
won't launch files based on extenstions/associations.  To use shell to
launch these, you need to call the actual program with  the file as a
command line arg.  ShellExecute will launch files based on extentions,
however.

Scott                               ICQ# 11107324
**************************************************
The views and opinions expressed by me
do not reflect those of KBSI.



Tue, 04 Sep 2001 03:00:00 GMT  
 Shell Function on NT 4.0 Platform
Try prefacing you command line with CMD to explicitly invoke the
command interpreter .ie.

 cmd$ = "cmd /c mybatch.bat"

See the NT help file for CMD options.


Quote:



>>Yes I have the same problem,
>>I want to execute a Java program and pass the user from system.environment
>>to my VB but shell command send me a number.
>>If you find it out let me know.
>>Thanks
>>Max


>>>    I have a problem running a Shell routine that call a Dos BAT file on
>>>NT4.0 using VB 6.0. I have incorporated this routine in a Class module and
>>>built it into a DLL. The problem is that when I run the Shell command it
>>>returns a Process ID but doesn't execute the batch command on NT 4.0. It
>>>Works on 95/98 and the development machine which is NT 4.0. Is there
>>>somthing I can change in the Deployment Wizard? Has any one had any
>>problems
>>>like this one.   Here is the code....

>>>  Dim ProcessID As Long
>>>   Dim PID As Long
>>>   Dim hProcess As Long
>>>   Dim hWndJob As Long
>>>   Dim nRet As Long
>>>   Dim TitleTmp As String
>>>   Const fdwAccess = PROCESS_QUERY_INFORMATION

>>>   If IsMissing(ExecMode) Then
>>>      ExecMode = vbMinimizedNoFocus
>>>   Else
>>>      If ExecMode < vbHide Or ExecMode > vbMinimizedNoFocus Then
>>>         ExecMode = vbMinimizedNoFocus
>>>      End If
>>>   End If

>>>   On Error Resume Next
>>>      ProcessID = Shell(JobToDo, CLng(ExecMode))        '    JobtoDo is a
>>>.Bat File
>>>      If Err Then
>>>         ShellAndClose = vbObjectError + Err.Number
>>>         Exit Function
>>>      End If
>>>   On Error GoTo 0

>>>   hWndJob = FindWindow(vbNullString, vbNullString)
>>>'    If hWndJob = 0 Then MsgBox " Skipping LooP"
>>>   Do Until hWndJob = 0
>>>      If GetParent(hWndJob) = 0 Then
>>>         Call GetWindowThreadProcessId(hWndJob, PID)
>>>         If PID = ProcessID Then Exit Do
>>>      End If
>>>      hWndJob = GetWindow(hWndJob, GW_HWNDNEXT)
>>>   Loop

>>>   hProcess = OpenProcess(fdwAccess, False, ProcessID)
>>>   Do   TitleTmp = Space(256)
>>>      nRet = GetWindowText(hWndJob, TitleTmp, Len(TitleTmp))
>>>      If nRet Then
>>>         TitleTmp = UCase(Left(TitleTmp, nRet))
>>>         If InStr(TitleTmp, "FINISHED") = 1 Then
>>>            Call SendMessage(hWndJob, WM_CLOSE, 0, 0)
>>>         End If
>>>      End If
>>>      GetExitCodeProcess hProcess, nRet
>>>      DoEvents
>>>      Sleep 100
>>>   Loop While nRet = STILL_ACTIVE
>>>   Call CloseHandle(hProcess)

>>>Thank You
>>>        Tom

>Look into the ShellExecute function and use it.  The shell function
>won't launch files based on extenstions/associations.  To use shell to
>launch these, you need to call the actual program with  the file as a
>command line arg.  ShellExecute will launch files based on extentions,
>however.

>Scott                               ICQ# 11107324
>**************************************************
>The views and opinions expressed by me
>do not reflect those of KBSI.

---------------------------------------------------------
Steve Czulewicz                stevecz at marc-iv.com
Marc-IV Technologies           http://www.marc-iv.com
Information Solutions for Individuals and Small Business


Mon, 10 Sep 2001 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Getting a PID, VB 4.0 32-bit, NT, Shell function

2. comctl32.ocx problem between NT 4.0 and Win95 platforms

3. Shell Function not shelling under Windows NT.

4. Problem with shell() under Windows NT 4.0

5. How do I get Shell.Application to work in NT 4.0

6. GetHostName API function not working for NT 4.0 (service pack 4)

7. Lock Workstation NT 4.0 Function

8. Lock Workstation NT 4.0 Function

9. Does WScript.Shell exist on all Windows platform ?

10. Shell.Application.Count or Shell.Application.Contents.Count

11. Shell & Shell Execute under NT

12. VB 4.0/SQL Retriever ODBC/AIX Platform/Oracle Database

 

 
Powered by phpBB® Forum Software