Cameron
Cameron

Reputation: 248

Python: Calling executable fails

I'm trying to run any one of these in Python...

subprocess.call(r"C:\Windows\System32\fsquirt.exe", shell=True)
subprocess.call("C:\\Windows\\System32\\fsquirt.exe", shell=True)
subprocess.call(r"C:/Windows/System32/fsquirt.exe", shell=True)
subprocess.call("C:/Windows/System32/fsquirt.exe", shell=True)

They all result in...

'C:/Windows/System32/fsquirt.exe' is not recognized as an internal or external command,
operable program or batch file.

If I just copy fsquirt.exe into the local directory I can call it from there, so I'm sure I must just be doing something noob-ish with how I'm using directories.

How should I do this?

Upvotes: 0

Views: 132

Answers (1)

Cameron
Cameron

Reputation: 248

The problem was that I'm using 64 bit Windows which doesn't use System32 (running from 32bit Python). 64 bit Windows typically uses SysWOW64 instead of System32. Calling the virtual directory Sysnative instead of either of those will sort out which one needs to be called based on what you're running (for me, 32bit Python). Fsquirt exists only in System32, not SysWOW64. This is different to something like Notepad which exists in both.

subprocess.call("C:/Windows/Sysnative/fsquirt.exe")

Upvotes: 1

Related Questions