Mod Tool/Scripting: Difference between revisions

read registry with forced 64/32-bit path
mNo edit summary
(read registry with forced 64/32-bit path)
Line 1: Line 1:
==General==
==General==
logmessage license
logmessage version
' examples:
' INFO : Softimage
' INFO : 13.0.114.0
' INFO : Mod Tool
' INFO : 7.5.203.0




Line 42: Line 33:


====Global variables====
====Global variables====
Any variable that gets defined outside a function or subroutine is a global variable.
Variables inside a function or sub are local. A local variable can only be used of the sub or function where it was declared.


Variables inside a function or sub are local.
Any variable that gets defined outside a function or subroutine is a global variable. Global variables can be used by any sub or function in the file.


A local variable can only be used of the sub or function where it was declared.


Global variables can be used by any sub or function in the file.
  ' global var 7
 
  ' global var
  MyVar7 = 3 + 0.3
  MyVar7 = 3 + 0.3


  sub test
  sub test
  ' local var
  ' local var 8
  MyVar8 = 3.3
  MyVar8 = 3.3
  end sub
  end sub


  function test2
  function test2
  ' local var
  ' local var 9 and 10
  MyVar9  = 3
  MyVar9  = 3
  MyVar10 = 4 + MyVar7
  MyVar10 = 4 + MyVar7
Line 182: Line 170:




==OS bit version==
==OS bitness==
  if GetObject("winmgmts:root\cimv2:Win32_Processor='cpu0'").AddressWidth = 64 then
  if GetObject("winmgmts:root\cimv2:Win32_Processor='cpu0'").AddressWidth = 64 then
  logmessage "64"
  logmessage "64"
Line 191: Line 179:
'''faster'''
'''faster'''
  Set WshShell = CreateObject("WScript.Shell")
  Set WshShell = CreateObject("WScript.Shell")
  if instr(WshShell.RegRead("HKLM\HARDWARE\DESCRIPTION\System\CentralProcessor\0\Identifier"), "x86") = 1 then
  if instr(WshShell.RegRead("HKLM\HARDWARE\DESCRIPTION\System\CentralProcessor\0\Identifier"), "64") > 0 then
logmessage "64"
else
  logmessage "32"
  logmessage "32"
else
logmessage "64"
  end if
  end if




==XSI/Softimage bit version==
==XSI/Softimage bitness, version and license==
There are three possibilities to detect the program's bitness:
 
logmessage Platform
  logmessage XSIUtils.ResolvePath("$XSI_CPU/")
  logmessage XSIUtils.ResolvePath("$XSI_CPU/")
  ' shows programm bit version
  logmessage XSIUtils.Is64BitOS
   
   
  ' example:
  ' output for 32-bit installation
  ' for 64-bit
' INFO : Win32
  ' INFO : nt-x86\
' INFO : False
' output for 64-bit installation
' INFO : Win64
  ' INFO : nt-x86-64\
  ' INFO : nt-x86-64\
   
  ' INFO : True
  ' for 32-bit
 
  ' INFO : nt-x86\
 
For program's version:
logmessage version
' examples:
' INFO : 13.0.114.0
  ' INFO : 7.5.203.0
 
For program's license:
logmessage license
' examples:
  ' INFO : Softimage
' INFO : Mod Tool
 
DAE files saved with XSI/Softimage contain license information.




==Read registry==
==Read registry==
Mod Tool (because 32-bit) fails to execute following code properly on 64-bit operation systems.
This reads the registry with forced 64/32-bit path (RegType). In this example Oni's install location gets revealed.
 
So the code must be build as 64-bit program on 64-bit OS '''and''' 32-bit program on 32-bit OS.


  Set WshShell = CreateObject("WScript.Shell")
  Set WshShell = CreateObject("WScript.Shell")
  AE_path = WshShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{B67333BB-1CF9-4EFD-A40B-E25B5CB4C8A7}}_is1\InstallLocation")
  if instr(WshShell.RegRead("HKLM\HARDWARE\DESCRIPTION\System\CentralProcessor\0\Identifier"), "64") > 0 then
  MsgBox AE_path
OS_bitness = 64
else
OS_bitness = 32
end if
Const HKEY_LOCAL_MACHINE = &H80000002
sPath = ReadRegStr (HKEY_LOCAL_MACHINE, _
"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{B67333BB-1CF9-4EFD-A40B-E25B5CB4C8A7}}_is1", _
"InstallLocation", _
OS_bitness)
logmessage sPath
Function ReadRegStr (RootKey, Key, Value, RegType)
  Dim oCtx, oLocator, oReg, oInParams, oOutParams
  Set oCtx = CreateObject("WbemScripting.SWbemNamedValueSet")
  oCtx.Add "__ProviderArchitecture", RegType
  Set oLocator = CreateObject("Wbemscripting.SWbemLocator")
  Set oReg = oLocator.ConnectServer("", "root\default", "", "", , , , oCtx).Get("StdRegProv")
  Set oInParams = oReg.Methods_("GetStringValue").InParameters
  oInParams.hDefKey = RootKey
  oInParams.sSubKeyName = Key
  oInParams.sValueName = Value
   
  Set oOutParams = oReg.ExecMethod_("GetStringValue", oInParams, , oCtx)
   
   
Dim fso
  ReadRegStr = oOutParams.sValue
Set fso = CreateObject ("Scripting.FileSystemObject")
  End Function
  txt_location = fso.GetAbsolutePathName(".") & "\AE_path.txt"
Set wText = fso.CreateTextFile (txt_location, 1)
wText.WriteLine AE_path
wText.Close




8,330

edits