Program Files and Program Files (x86)
Hi all,
I am a novice when it comes to scripting and I am having the toughest time getting this to work.
Baisclly, I am trying to install a package silently and after the install, I need a .ini to be copied to the correct location in the program files folder. Our enviroment is 32 bit and 64 bit. I had a simple script that worked but I was copying to "C:\Program Files\App" worked good on everything expect 64 bit systems because the files are in Program Files (x86).
Tried using the script below, but I could not get it to work... anyone have any ideas? Would greatly appreictae it.
@ECHO OFF Set objFSO = CreateObject("Scripting.FileSystemObject") If objFSO.FolderExists("c:\program files (x86)") Then Session.Property("ProgramFiles") = "c:\program files (x86)" Else Session.Property("ProgramFiles") = "c:\program files" End If start /wait xcopy "Config.ini" “[ProgramFiles]\App\” /y
Answers (2)
Here is a script that I wrote using a function created by Darwin Sanoy, which is referenced in the code should you wish to look it up. I use this script to check if the OS is 32 bit or 64 bit whenever such a requirement as yours exists.
However, can you not just add your ini file to the MSI via a transform and let the MSI sort out the 32 bit placement automatically?
'Check whether the OS is 32 bit or 64 bit
'Written by EdT with credit to Darwin Sanoy for function used.
'Initial Release 19/02/2013
Dim WshShell, ret, reg32, reg64,ProdCode,DisplayName, dnv, bits
On Error Resume Next
Set WshShell = CreateObject("WScript.Shell")
bits = CSI_GetBitness("OS")
wscript.quit (bits)
'* Name: CSI_GetBitness.vbs
'* Author: Darwin Sanoy
'* Updates: http://csi-windows.com/community
'* Bug Reports &
'* Enhancement Req: http://csi-windows.com/contactus
'wscript.echo "The CSI_GetHWBits function reports that your Hardware is " & CSI_GetBitness("Hardware") & " Bits"
'wscript.echo "The CSI_GetOSBits function reports that your Windows OS is " & CSI_GetBitness("OS") & " Bits"
'wscript.echo "The CSI_GetProcBits function reports that your process is running as " & CSI_GetBitness("Process") & " Bits"
Function CSI_GetBitness(Target)
'CSI_GetBitness Function - updates at http://csi-windows.com.
' All bitness checks in one function
Select Case Ucase(Target)
Case "OS", "WINDOWS", "OPERATING SYSTEM"
CSI_GetBitness = GetObject("winmgmts:root\cimv2:Win32_Processor='cpu0'").AddressWidth
Case "HW", "HARDWARE"
CSI_GetBitness = GetObject("winmgmts:root\cimv2:Win32_Processor='cpu0'").DataWidth
Case "PROCESS", "PROC"
'One liner to retrieve process architecture string which will reveal if running in 32bit subsystem
ProcessArch = CreateObject("WScript.Shell").Environment("Process")("PROCESSOR_ARCHITECTURE")
If lcase(ProcessArch) = "x86" Then
CSI_GetBitness = 32
Else
If instr(1,"AMD64,IA64",ProcessArch,1) > 0 Then
CSI_GetBitness = 64
Else
CSI_GetBitness = 0 'unknown processor architecture
End If
End If
Case Else
CSI_GetBitness = 999 'unknown Target item (OS, Hardware, Process)
End Select
End Function