Henning
10/2/2010 11:30:00 PM
"Norm" <NormF4@Spoof.com> skrev i meddelandet
news:i8883f$614$1@news.eternal-september.org...
> Helmut_Meukel used his keyboard to write :
>> Norm schrieb :
>>> Nobody formulated the question :
>>>> "Norm" <NormF4@Spoof.com> wrote in message
>>>> news:i87q89$rbf$1@news.eternal-september.org...
>>>>> Now I am stumped, when I was testing earlier the return value was 42,
>>>>> which I believe means it was working, but the program did not start. I
>>>>> left to go eat breakfast and shut the computer down.
>>>>>
>>>>> Upon testing again I get the same return value, but now the program I
>>>>> am trying to start, does start.
>>>>>
>>>>> Another one of those things to remind me when it is not working and I
>>>>> am not sure why, reboot the computer and try again. :-)
>>>>
>>>> I tested shelling a copy of Notepad under Windows 7 32-Bit with a path
>>>> with spaces on it, and I got successful return value(42), but Notepad
>>>> didn't start or at least I don't see it in Task Manager, whether I used
>>>> Shell or ShellExecute. Then I replaced the Notepad.exe copy with a VB6
>>>> made EXE, and it showed up. Here is my code, add two command buttons to
>>>> test it, and put a copy of Notepad in a subfolder named "Test 1", with
>>>> a space between "Test" and "1".
>>>>
>>>> Option Explicit
>>>>
>>>> Private Const SW_SHOWNORMAL = 1
>>>> 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
>>>>
>>>> Private Sub Command1_Click()
>>>> Shell App.Path & "\Test 1\Notepad.exe", vbNormalFocus
>>>> End Sub
>>>>
>>>> Private Sub Command2_Click()
>>>> Dim ret As Long
>>>> ret = ShellExecute(Me.hwnd, "Open", App.Path & "\Test
>>>> 1\Notepad.exe", _
>>>> "", "", SW_SHOWNORMAL)
>>>> MsgBox "ShellExecute returned " & ret & ", LastDllError = " & _
>>>> Err.LastDllError
>>>> End Sub
>>>
>>> I spoke too soon before, as I had forgoten to comment out the Shell
>>> line. I should know not to keep working with no sleep. :-)
>>>
>>> I tried your test and got two different results. If I just opened a new
>>> VB6 and printed out app.path it showed C:\Windows\System32 so I created
>>> a folder called Test 1 and put Notepad into it, but neither shell or
>>> shellexecute would run. Shell stated file not found, shellexecute
>>> returned an error of 2. But thinking about it I am using Win7 64 bit, so
>>> even though app.path returns System32 I wonder if it should be under
>>> Wow.
>>>
>>> Anyway I saved the project to another drive copied the Test 1 folder
>>> there and both Shell and ShellExecute worked fine.
>>>
>>> I am not sure why the one file of mine will not run, there are a lot of
>>> other paths with spaces in them and they work just fine. Maybe we
>>> tripped over a bug in Win7.
>>>
>>> I have been going nuts all day trying to add the desktop icons to the
>>> shortcuts I load from the desktop. I create the menu's on the fly and so
>>> far have not had any luck with adding the icons.
>>>
>>> Anyway let me know if you figure out why that is not working on your
>>> system.
>>>
>>
>> Curiouser and curiouser.
>> I just tried it on my Win7 system (just the Shell):
>> I had opened TaskManager/processes to see what happens.
>> Sometimes TaskManager shows notepad.exe but it will always go away
>> immediadtely. I think the other times the execution time was too short
>> to show up in TaskManager.
>> The directory was on an other drive with no restrictions.
>> I tried it both ways, logged on as Admin and VB6 started normal and
>> VB6 started right-clicked as Admin. No change.
>>
>> Helmut.
>
> Hi Helmut,
>
> I am beginning the think I might have stumbled across something that is
> not my fault. :-)
>
> Norm
>
>
From what I read in nobodys reply. Create a Folder anyname, copy
Notepad.exe -> Test 1.exe and run his code.
/Henning