OT: How does Windows handle spaces in program names?

Mike Bonner bonnmike at gmail.com
Sun May 22 15:36:38 EDT 2011


If you slightly change kens script to this

*Set ProcessSet
=GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2").ExecQuery("Select
* from Win32_Process")*
*
*
*tList = ""*
*For each Process in ProcessSet*
*   if Process.ExecutablePath <> "" Then*
*       tList = tList & Process.Name & vbcrlf*
*  End If*
*Next*
*'wScript.stdout tList*
*result = tList*
*
*
and put it into a property, then you don't have to make a temp file. It will
put the list of running processes into the result where you can do with it
what you will.  Will still need to escape any paths and or filenames to
handle the spaces when using launch, but this gives a nice neat little list
of processes.  Thx much Mr Ray. the shortfilepath is still probably the
easiest way to handle spaces in paths since it eliminates them entirely.

On Sun, May 22, 2011 at 1:19 PM, Mike Bonner <bonnmike at gmail.com> wrote:

> Ah k, nvm. The impersonation stuff designates access level.
>
>
> On Sun, May 22, 2011 at 1:14 PM, Mike Bonner <bonnmike at gmail.com> wrote:
>
>> I don't understand Ken Rays script, will have to look things up.
>>
>> I don't know for sure, but I suspect a standard backslash is used to
>> escape chars in vb scripts so if you had an executable named "fred
>> schmed.exe" to make it work it would be "fred\ schmed.exe"
>>
>> Also, if you have a path with spaces in it, you can use shortfilepath to
>> change it into a usable form with no escaping required.  For example, if
>> you're trying to execute livecode from a standalone..
>>
>> put the shortfilepath of "C:\Program Files (x86)\RunRev\LiveCode
>> 4.6\LiveCode.exe" into tPath
>> then tPath will contain C:\PROGRA~2\RunRev\LIVECO~1.6\LiveCode.exe  no
>> spaces, works fine.
>>
>> If an executable is in the path and you put the shortfilepath of
>> "executable name with spaces.exe" I don't know if it will correctly return
>> the shortened version of the filename without supplying the whole path, but
>> it might.
>>
>> Also, can't take credit for the script, snitched it with only minor
>> modifications.
>>
>> Ken, does your code return a list in shortened version?  Seems like thats
>> what the whole impersonation stuff would be about. (goes to try it)
>>
>> On Sun, May 22, 2011 at 12:04 PM, Ken Ray <kray at sonsothunder.com> wrote:
>>
>>>
>>>
>>> > It would be helpful of course if I could see the process list in the PC
>>> - then
>>> > I could launch the prog from outside my LC app and just look at the
>>> list to
>>> > see what Windows calls it, but I don't know how to do that on XP since
>>> > 'tasklist' isn't recognised and I don't know how to display things from
>>> a VB
>>> > script. It's sad to be so ignorant, but the charm of LiveCode is that
>>> you
>>> > don't normally have to know this kind of stuff about your target OS.
>>>
>>> Here you go - this is a VBScript that will do it (watch line wraps):
>>>
>>> Set ProcessSet =
>>>
>>> GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2").ExecQu
>>> ery("Select * from Win32_Process")
>>>
>>> tList = ""
>>> For each Process in ProcessSet
>>>    if Process.ExecutablePath <> "" Then
>>>        tList = tList & "Process.Name" & vbcrlf
>>>    End If
>>> Next
>>> WScript.Echo tList
>>>
>>> Ken Ray
>>> Sons of Thunder Software, Inc.
>>> Email: kray at sonsothunder.com
>>> Web Site: http://www.sonsothunder.com/
>>>
>>>
>>>
>>> _______________________________________________
>>> use-livecode mailing list
>>> use-livecode at lists.runrev.com
>>> Please visit this url to subscribe, unsubscribe and manage your
>>> subscription preferences:
>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>>
>>
>>
>



More information about the use-livecode mailing list