PDA

View Full Version : Help finding 3dsMax default installation and Bit version


Norman3D
01-13-2011, 02:15 PM
Hello! Maybe you guys can help me out...

So I need to write a script that finds the default 3dsMax installation (The 3dsmax version that is used when opening a max file from explorer) and I need to know whether it's 32bit or 64 bit.

In order to find the exe I checked the DefaultIcon path in the registry that .max files use.
So now that I have the path to the 3dsMax.exe, I need to know if that installation is 64 bit or 32bit.

I found this in the reference:
is64bitApplication()

But it only checks if the 3dsMax version you are running at the moment is 64bit or not.

Do you guys have any idea how I can find out if a certain 3dsMax installation is 32bit or 64bit?

lo
01-13-2011, 10:08 PM
This is by no means a watertight method, and assumes that on a 64-bit machine you would install 32-bit max in program files x86 and 64-bit max in program files, but you could try to test if:
systemTools.getEnvVariable "programfiles(x86)"!=undefined
that way you know if you are on a 64-bit system or a 32-bit system.


Another not amazing option:
((dotnetclass "system.diagnostics.process").getcurrentProcess()).MainModule.filename
you can check if the current running version of max is the executable you found, and assume that if is64bitapplication() returns true then it is 64-bit max, and if not then it is 32-bit max.

Of course, this would not be certain if you had more than 2 executables of max installed (for example, two verisons of 3dsmax each in 32-bit and 64-bit)

JHN
01-14-2011, 12:37 PM
There are more options but you have to resort to c#.net.
I'll see if I can put something up, as I have made a tool that figures this problem out automatically.
-Johan

lo
01-14-2011, 02:25 PM
what methods would use to get the bit type of an EXE without running it as a process?

Gravey
01-14-2011, 03:23 PM
after googling "c# get file associations" and poking around i found this nice dll (http://www.codeproject.com/KB/cs/AF_FileAssociation.aspx) at codeproject

download the dll and then getting the path to the 3dsmax.exe which opens by default is easy:
dotnet.loadAssembly @"X:\my path to the dll\AF_FileAssociations.dll"
a = dotnetobject "Associations.AF_FileAssociator" ".max"
a.Executable.Path -- returns the path to 3dsmax.exe
-- note that the path string has an extra set of quotes "" in the string
so you'll need to use substring or filterstring to get a useable path.


EDIT: In case anyone saw it, I was wrong about the first result on google. Not sure how I got to the linked page above. The solution works regardless

j83
01-15-2011, 07:52 PM
(
max32file = (getDir #maxroot) + "max32.task"
max64file = (getDir #maxroot) + "max64.task"

if ((getfiles max32file).count != 0) then
(
messageBox "You're running a 32-bit version of Max" beep:false
)

if ((getfiles max64file).count != 0) then
(
messageBox "You're running a 64-bit version of Max" beep:false
)

-- format "\nMax32 % \nMax64 %" max32file max64file
)


Of course, it wouldn't be fullproof if for some reason the files got moved around, but as long as the installation was normally, that might work for you. :)

Norman3D
01-16-2011, 10:07 PM
(
max32file = (getDir #maxroot) + "max32.task"
max64file = (getDir #maxroot) + "max64.task"

if ((getfiles max32file).count != 0) then
(
messageBox "You're running a 32-bit version of Max" beep:false
)

if ((getfiles max64file).count != 0) then
(
messageBox "You're running a 64-bit version of Max" beep:false
)

-- format "\nMax32 % \nMax64 %" max32file max64file
)


Of course, it wouldn't be fullproof if for some reason the files got moved around, but as long as the installation was normally, that might work for you. :)

Great! That's exactly what I was looking for! Thanks! :applause:

j83
01-17-2011, 03:11 PM
Glad to hear. :D

lo
01-17-2011, 03:42 PM
Great! That's exactly what I was looking for! Thanks! :applause:

how is this what you're looking for? Doesn't it just return whether or not the currently running max is 64-bit or 32-bit?
How is it different than is64bitapplication() ?

Norman3D
01-17-2011, 05:22 PM
how is this what you're looking for? Doesn't it just return whether or not the currently running max is 64-bit or 32-bit?
How is it different than is64bitapplication() ?

well, (getDir #maxroot), gives you the full path to the 3dsMax root folder, doesn't it?

So I assume that I could replace that with any other 3dsMax root folder in my PC. To be honest I haven't really tried it out yet, since I'm stuck on a 32 bit machine at the moment.

There should be no difference between:

max32file = (getDir #maxroot) + "max32.task"
and
max32file = "C:\\Program Files\\Autodesk\\3ds Max 2011\\" + "max32.task"

right? :curious:

j83
01-17-2011, 05:27 PM
On a 64-bit Windows install, the 32 bit path would contain (x86) in its name (by default), and the 64-bit path would not have "(x86)" in its file path name.

:)

Either way, we just use "getDir #maxroot" to get the correct directory, no matter where Max is installed. Much, much better than hard-coding file paths.

Norman3D
01-17-2011, 06:03 PM
On a 64-bit Windows install, the 32 bit path would contain (x86) in its name (by default), and the 64-bit path would not have "(x86)" in its file path name.

:)

Either way, we just use "getDir #maxroot" to get the correct directory, no matter where Max is installed. Much, much better than hard-coding file paths.

Getting the path to the 3dsMax root folder is not a problem in my case, whether it's 32bit or 64bit. I essentially get a list of 3dsMax.exe path's from somewhere else. And I need maxscript to figure out if they are 32 or 64 bit.

And checking whether max32.task exists or not, I can determine if it's a 32 bit or 64 bit installation.

Thanks again :)

lo
01-17-2011, 07:04 PM
Getting the path to the 3dsMax root folder is not a problem in my case, whether it's 32bit or 64bit. I essentially get a list of 3dsMax.exe path's from somewhere else. And I need maxscript to figure out if they are 32 or 64 bit.

And checking whether max32.task exists or not, I can determine if it's a 32 bit or 64 bit installation.

Thanks again :)

you're right, that makes much more sense

denisT
01-17-2011, 08:18 PM
And checking whether max32.task exists or not, I can determine if it's a 32 bit or 64 bit installation.


I'm just curious. Why do you need it to know in stage when the MAX is already running? Why do you care about the bit version of an associated MAX and not care about MAX's version for example?

Norman3D
01-17-2011, 10:18 PM
I'm creating a script that needs to check for other "installations" of the same script in other 3dsMax installations.
So I got the path to the 3dsmax.exe through a txt, and I just needed to know if it was 32bit or 64bit in order to be able to "reconstruct" the "userscripts" folder properly.

But actually, I'm doing it completely different right now. I'm just having my script writing some info in the registry. Then when the user makes a second install of it, on another 3dsmax installation I just check the registry for previous entries so I'm able to tell if there were other installs of my script and if so where.

Hopefully I'll be able to show my script in a couple of weeks, because I think it's pretty cool ;)

biddle
01-20-2011, 11:37 PM
Here is a DOS batch file that will dump out the install directories for different versions of Max on your system.

You can use it to locate files without actually launching max.

I've used it as a basis for copying compiled plugins to their correct destinations as part of a Visual Studio post-build step.

ECHO off

REM Call wmic and set errorlevel == 1 if we are on a 32 bit system
wmic path win32_processor get addresswidth /format:list | find "=64" 1>nul

FOR %%V in (2008_10.0 2009_11.0 2010_12.0 2011_13.0 2012_14.0) do (

FOR /F "tokens=1,2 delims=_" %%A in ("%%V") do (

IF NOT ERRORLEVEL 1 (
REM this is a 64 bit OS
FOR /F "tokens=2* delims= " %%P in ('reg query "HKLM\software\wow6432node\autodesk\3dsmax\%%B\max-1:409" /v installdir /reg:64 ^2^>nul') DO (
ECHO Max %%A 32 bit is installed in %%Q
)
FOR /F "tokens=2* delims= " %%P in ('reg query "HKLM\software\autodesk\3dsmax\%%B\max-1:409" /v installdir /reg:64 ^2^>nul') DO (
ECHO Max %%A 64 bit is installed in %%Q
)

) ELSE (

REM this is a 32 bit OS
FOR /F "tokens=2* delims= " %%P in ('reg query "HKLM\software\autodesk\3dsmax\%%B\max-1:409" /v installdir ^2^>nul'') DO (
ECHO Max %%A 32 bit is installed in %%Q
)

)
)
)

Norman3D
01-21-2011, 01:48 AM
oh! Great! I'm sure this will come in handy quite soon! :thumbsup:

CGTalk Moderation
01-21-2011, 01:48 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.