Разве строка for file in filenames:
не должна быть for file in fileList:
?
Также я думаю, что это правильный способ использования os.walk()
import os
fileList = []
keywordList = []
for root, dirs, files in os.walk('/Users/Me/Api/downloaded', topdown=False):
for name in files:
fileList.append(os.path.join(root, name))
for file in fileList:
with open(file, encoding='utf-8', mode='r') as currentFile:
keywordList.append(currentFile['keyword'])
print(keywordList)
Have you tried checking the return value of the Shell function? Documentation says it should return zero if the shell fails.
Martin says in the comments: I tried, but every time I check the return value, is some weird number greater than zero.
MarkJ again: The return values are supposed to be process IDs. It might be possible to make an API call to check whether they are valid process IDs. You could try something like this: this always shows a "succeeded" MsgBox for me, because I don't have Vista Starter Edition :)
Private Declare Function OpenProcess Lib "kernel32" ( _
ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, _
ByVal dwProcessId As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" ( _
ByVal hObject As Long) As Long
Sub StartProcess()
Dim ProcessId&
Dim hProcess&
Const PROCESS_QUERY_INFORMATION = &H400&
ProcessId = Shell("notepad.exe", vbNormalFocus)
hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, False, ProcessId)
If hProcess = 0& Then
MsgBox "Failed"
Else
MsgBox "Succeeded"
CloseHandle hProcess
End If
End Sub
Почему вы не используете интерфейс ImageMagickObject COM +? Я никогда не использовал его, но в документации утверждается, что он может делать все, что могут утилиты командной строки, без запуска дополнительных приложений.
Не то, что вы хотели услышать, но готов поспорить, что "стартер" достаточно легко сломать.
Готов поспорить, работает что-то вроде этого: загрузить системную службу, взять SE_DEBUG , пройдемся по всем процессам, исправив GetSystemMetrics (0x88), чтобы вернуть 0 в ОЗУ.
Вздох
Не обращайте внимания, в будущем мне нужно читать дальше темы!
Вызовите GetSystemMetrics (), передав SM_STARTER (a Const = 88).
Option Explicit
Private Const SM_STARTER = 88&
Private Declare Function GetSystemMetrics Lib "user32" ( _
ByVal nIndex As Long) As Long
Private Sub Form_Load()
MsgBox CStr(GetSystemMetrics(SM_STARTER)) 'Zero (0) means False.
End Sub
Это определено для XP и должно быть таким же для Vista. Достаточно легко попробовать, правда?
Try starting with createprocess instead of via the shell? Or have a service manage it, while the app communicates with the service.