Hello everybody ,

I've a simple batch file and want to execute in VB6 :

@echo off
TASKKILL /IM explorer.exe /F
start explorer

It's very simple , I name this batch to perm.cmd. But for Windows 8 , it need administrator's right to execute this perm.cmd , so I made a shortcut of it named it to perm.lnk
In this perm.lnk's property , I change it to run with administrator's right. So when I double click this perm.lnk , it runs fine.
The 2 task line in the perm.cmd can both be executed.

I write this perm.cmd in VB6 and name it as test.exe like this :

Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" ( _
ByVal hWnd As Long, ByVal lpOperation As String, ByVal lpFile As String, _
ByVal lpParameters As String, ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long

Dim sPath As String
Dim sFName As String
--------------------------------------------------------------------------------------------
Private Sub Form_Load()
'-- sPath may or may not end with \
sPath = "D:\ABC"
sFName = "perm.lnk"
If Len(Dir(sPath & "\" & sFName)) = 0 Then
MsgBox "File not found: " & sPath & "\" & sFName
Else
ShellExecute 0, "Open", sFName, "", sPath, 0
End If
End Sub

I can use VB6 test.exe to run perm.lnk , it works , but it only execute the first line in the perm.cmd , i.e.

TASKKILL /IM explorer.exe /F

But the second line in the perm.cmd can't be execute , i.e.

start explorer

I feel very strange why I can run perm.lnk perfectly , but not the test.exe in VB6 ?

Can anyone help me please ? Thanks a lot.