|
-
Jan 30th, 2011, 07:34 AM
#1
Thread Starter
Addicted Member
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
-
Jan 30th, 2011, 08:45 AM
#2
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.
-
Jan 30th, 2011, 07:18 PM
#3
Thread Starter
Addicted Member
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
-
Jan 30th, 2011, 09:31 PM
#4
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
-
Jan 30th, 2011, 11:33 PM
#5
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.
-
Jan 31st, 2011, 12:36 AM
#6
Thread Starter
Addicted Member
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?
-
Jan 31st, 2011, 05:39 AM
#7
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.
-
Jan 31st, 2011, 07:26 AM
#8
Thread Starter
Addicted Member
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.
-
Jan 31st, 2011, 08:32 AM
#9
Re: Dir in windows 7
According to this:
http://commandwindows.com/taskkill.htm
 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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|