Results 1 to 9 of 9

Thread: Dir in windows 7

  1. #1

    Thread Starter
    Addicted Member Witis's Avatar
    Join Date
    Jan 2011
    Location
    VB Forums Online Freedom Mode: Operational
    Posts
    213

    Dir in windows 7

    Can anyone tell me why the following code returns 0 on windows 7?

    Private Sub Command1_Click()
    MsgBox Len(Dir("c:\windows\system32\tskill.exe"))
    End Sub

  2. #2
    Only Slightly Obsessive jemidiah's Avatar
    Join Date
    Apr 2002
    Posts
    2,431

    Re: Dir in windows 7

    The file apparently does not exist. 64 bit editions of windows store their 32-bit binaries in Windows\SysWOW64 and their 64-bit binaries in Windows\system32. Yes, this is confusing. Perhaps that's what you're running into.
    The time you enjoy wasting is not wasted time.
    Bertrand Russell

    <- Remember to rate posts you find helpful.

  3. #3

    Thread Starter
    Addicted Member Witis's Avatar
    Join Date
    Jan 2011
    Location
    VB Forums Online Freedom Mode: Operational
    Posts
    213

    Re: Dir in windows 7

    Hi jemidiah

    Thanks for your relpy, although I couldn't find tskill in the Windows\SysWOW64\ directory. Also if that is the case why does this code find taskkill in the same directory?

    Private Sub Command1_Click()
    MsgBox Len(Dir("c:\windows\system32\taskkill.exe"))
    End Sub

  4. #4
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Dir in windows 7

    maybe it is not included with win 7?

    edit: i found tskill.exe here
    "C:\Windows\winsxs\x86_microsoft-windows-t..es-commandlinetools_31bf3856ad364e35_6.1.7600.16385_none_e486af895a57d1b2\tskill.exe"
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  5. #5
    Only Slightly Obsessive jemidiah's Avatar
    Join Date
    Apr 2002
    Posts
    2,431

    Re: Dir in windows 7

    For what it's worth, I searched my own Vista 64 (Personal or something like that edition) for tskill.exe and didn't find it.

    Also if that is the case why does this code find taskkill in the same directory?
    I think the answer's obvious--taskkill.exe is apparently a 64 bit binary, or someone put it in the wrong place on accident. I wasn't saying tskill.exe is necessarily 32 bit, just that it could be. It doesn't seem to be installed on all Windows machines, which you'll have to work around somehow.
    The time you enjoy wasting is not wasted time.
    Bertrand Russell

    <- Remember to rate posts you find helpful.

  6. #6

    Thread Starter
    Addicted Member Witis's Avatar
    Join Date
    Jan 2011
    Location
    VB Forums Online Freedom Mode: Operational
    Posts
    213

    Re: Dir in windows 7

    Hi westconn1

    The problem is that I can see tskill in the windows\system32 directory and I can use start->type "run"->type "tskill + app|pid" on Win 7 although when I try and run a dir command the file can't be seen.

    jemidiah, I have read on the net that tskill should be in vista, I am not sure why you couldn't find it - is it in another directory?

    It is weird behavior that I can see and shell taskkill located in windows\system32\ but not tskill. Could it be that taskkill is a 32bit application, where as tskill is a 64bit application, and the dir call to the 64 bit tskill get redirected to the C:\Windows\SysWOW64\ directory which does not contain tskill.exe?

    This seems to be the workaround: use sysnative in place of system32, so Msgbox dir("c:\windows\sysnative\tskill.exe") prevents the dir call from looking in the syswow64 and gets it to check \system32 instead. It worked for me on 7, how about on vista?

  7. #7
    Only Slightly Obsessive jemidiah's Avatar
    Join Date
    Apr 2002
    Posts
    2,431

    Re: Dir in windows 7

    I searched my entire hard drive and didn't find any tskill.exe. If the file does exist and you're just not able to Dir it, you might try adding the Read Only, Hidden, and System attributes to the call (elaborated here).

    I did find taskkill.exe in both Windows\System32 and Windows\SysWOW64.

    and the dir call to the 64 bit tskill get redirected to the C:\Windows\SysWOW64\ directory which does not contain tskill.exe?
    It would seem so. This page contains more information on file system redirection while running 32 bit programs on 64 bit versions of Windows. In particular it says "The Sysnative alias was added starting with Windows Vista", so your sysnative workaround should be safe as long as the file actually exists.
    The time you enjoy wasting is not wasted time.
    Bertrand Russell

    <- Remember to rate posts you find helpful.

  8. #8

    Thread Starter
    Addicted Member Witis's Avatar
    Join Date
    Jan 2011
    Location
    VB Forums Online Freedom Mode: Operational
    Posts
    213

    Re: Dir in windows 7

    ok it could be that only some versions of vista have it eg Vista Ultimate SP1 x64. Thanks for clearing that up jemidiah, just one of those moving to 64bit problems.

  9. #9
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: Dir in windows 7

    According to this:
    http://commandwindows.com/taskkill.htm

    Quote Originally Posted by From_Link
    Both the Home and Professional version of Windows XP come with the tool Tskill . In addition, XP Professional has the more powerful tool Taskkill.
    So it would seem the difference is probably the version of Windows...

    There's more here:
    http://www.velocityreviews.com/forum...der-wow64.html


    -- It wouldn't surprise me if tskill was aliased to taskkill or vice versa in the registry somewhere... which is why tskill works from a commandline while you can't find the file in the directory. Or it could be hidden.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width