Jump to content











Photo
- - - - -

Detect OS version 32/64bit in script

win8 script os version

Best Answer homes32 , 09 May 2014 - 02:17 PM

peter is correct. you seem to be off on the wrong track here. The architecture of program you use is dependent on the arch of the PE you are building. A program running in PE does not care what operating system is on the host nor is it affected by its arch.
 
In short.

  • If you are building your Win8.1_PE_SE with a x86 source disk you will need to use x86 applications.
  • If you are building your Win8.1_PE_SE with a x64 source disk you can use either one but with the kind of programs usually run in a PE environment there is little advantage to x64 over x86 as they generally have a small memory footprint as it is.
     
    There is no advantage to including both x86 and x64 version of the same program in your PE. Use the one that makes sense for your PE Build.
     
     
    Now that we have that out of the way here is how you can achieve a script that will build the native arch exe into your project:

    In the attachments tab of the script editor make 2 folders
  • x86
  • x64

    and place the appropriate binary in each folder.
     
    [main]
    Title=NTPWEdit
    Description=Removes passwords
    Selected=True
    Level=5
    Version=1
     
    [variables]
    %ProgramTitle%=NTPWEdit
    %ProgramEXE%=ntpwedit.exe
    %ProgramFolder%=NTPWEdit
     
    [process]
    // %SourceArch% is a project defined variable who's value will be
    // either x86 or x64 depending on the arch of the SOURCE (aka the PE you are building)
    // in the example below we are telling winbuilder to extract all files attached to
    // the script from the folder name defined by %SourceArch%
    //
    ExtractAllFiles,%ScriptFile%,%SourceArch%,%ProgramFolder%
    Add_Shortcut,StartMenu,Security\%ProgramTitle%,%PE_Programs%\%ProgramFolder%\%ProgramEXE%,%ProgramTitle%
    
    
    regards,
    Homes32
Go to the full post


  • Please log in to reply
6 replies to this topic

#1 MasterG

MasterG
  • Members
  • 8 posts
  •  
    Greece

Posted 08 May 2014 - 02:08 PM

I am using Winbuilder with Win8.1SE and i have numerous programs that have 32bit and 64bit executables for the same application.
I prefer to use 64bit Windows but there is also a requirement for 32bit Windows on older x86 architecture.
Is there a command that I can use in Winbuilder to detect if Windows 32bit or 64bit is being used so that i can then add the relevant file version for the application?
 



#2 pscEx

pscEx

    Platinum Member

  • Team Reboot
  • 12686 posts
  • Location:Korschenbroich, Germany
  • Interests:What somebody else cannot do.
  •  
    European Union

Posted 08 May 2014 - 02:25 PM

I'm not sure whether you mean the architecture of your host OS, or the architecture of the source CD.

WinBuilder variable %Wow64% is True or False, depending on the architecture of your host.

 

Peter



#3 MasterG

MasterG
  • Members
  • 8 posts
  •  
    Greece

Posted 08 May 2014 - 03:00 PM

This is a sample script:
 

[main]
Title=NTPWEdit
Description=Removes passwords
Selected=True
Level=5
Version=1
 
[variables]
%ProgramTitle32%=NTPWEdit 32bit
%ProgramTitle64%=NTPWEdit 64bit
%ProgramEXE%=ntpwedit.exe
%ProgramEXE64%=ntpwedit64.exe
%ProgramFolder%=NTPWEdit
 
[process]
CopyProgram,%ScriptDir%\%ProgramFolder%
Add_Shortcut,StartMenu,Security\%ProgramTitle%,%PE_Programs%\%ProgramFolder%\%ProgramEXE%,%ProgramTitle32%
Add_Shortcut,StartMenu,Security\%ProgramTitle%,%PE_Programs%\%ProgramFolder%\%ProgramEXE64%,%ProgramTitle64%
unpack
 
 
So i change the shortcut line to:
if,true,%WOW64%,Add_Shortcut,StartMenu,Security\%ProgramTitle%,%PE_Programs%\%ProgramFolder%\%ProgramEXE64%,%ProgramTitle64%,else,Add_Shortcut,StartMenu,Security\%ProgramTitle%,%PE_Programs%\%ProgramFolder%\%ProgramEXE%,%ProgramTitle32%

Would that work?


#4 pscEx

pscEx

    Platinum Member

  • Team Reboot
  • 12686 posts
  • Location:Korschenbroich, Germany
  • Interests:What somebody else cannot do.
  •  
    European Union

Posted 08 May 2014 - 03:24 PM

So i change the shortcut line to:
if,true,%WOW64%,Add_Shortcut,StartMenu,Security\%ProgramTitle%,%PE_Programs%\%ProgramFolder%\%ProgramEXE64%,%ProgramTitle64%,else,Add_Shortcut,StartMenu,Security\%ProgramTitle%,%PE_Programs%\%ProgramFolder%\%ProgramEXE%,%ProgramTitle32%

Would that work?

 

Syntax should be:

If,%Wow64%,EQUAL,True,Add_Shortcut,StartMenu,Security\%ProgramTitle%,%PE_Programs%\%ProgramFolder%%ProgramEXE64%,%ProgramTitle64%
Else,Add_Shortcut,StartMenu,Security\%ProgramTitle%,%PE_Programs%%ProgramFolder%\%ProgramEXE%,%ProgramTitle32% 

Take care of the new line instead comma before else.

IMO there is a backslash missing in the first line behind %ProgramFolder%

And in the second line behind %PE_Programs%

I do not know how the shortcut is generated in your project, but distinguishing between x86 and x64 should work.

 

Peter



#5 pscEx

pscEx

    Platinum Member

  • Team Reboot
  • 12686 posts
  • Location:Korschenbroich, Germany
  • Interests:What somebody else cannot do.
  •  
    European Union

Posted 08 May 2014 - 03:58 PM

Just a remark:

 

I have the feeling that you are searching in the wrong direction.

 

As far as I understand, you want to start by shortcut either an x86 or x64 application in the running PE.

 

Why the OS of the PE-building program determines whether x86 or x64 is started? :dubbio:

 

That should depend on the architecture of the generated PE! :whistling:

 

Peter



#6 homes32

homes32

    Gold Member

  • .script developer
  • 1021 posts
  • Location:Minnesota
  •  
    United States

Posted 09 May 2014 - 02:17 PM   Best Answer

peter is correct. you seem to be off on the wrong track here. The architecture of program you use is dependent on the arch of the PE you are building. A program running in PE does not care what operating system is on the host nor is it affected by its arch.
 
In short.
  • If you are building your Win8.1_PE_SE with a x86 source disk you will need to use x86 applications.
  • If you are building your Win8.1_PE_SE with a x64 source disk you can use either one but with the kind of programs usually run in a PE environment there is little advantage to x64 over x86 as they generally have a small memory footprint as it is.
     
    There is no advantage to including both x86 and x64 version of the same program in your PE. Use the one that makes sense for your PE Build.
     
     
    Now that we have that out of the way here is how you can achieve a script that will build the native arch exe into your project:

    In the attachments tab of the script editor make 2 folders
  • x86
  • x64

    and place the appropriate binary in each folder.
     
    [main]
    Title=NTPWEdit
    Description=Removes passwords
    Selected=True
    Level=5
    Version=1
     
    [variables]
    %ProgramTitle%=NTPWEdit
    %ProgramEXE%=ntpwedit.exe
    %ProgramFolder%=NTPWEdit
     
    [process]
    // %SourceArch% is a project defined variable who's value will be
    // either x86 or x64 depending on the arch of the SOURCE (aka the PE you are building)
    // in the example below we are telling winbuilder to extract all files attached to
    // the script from the folder name defined by %SourceArch%
    //
    ExtractAllFiles,%ScriptFile%,%SourceArch%,%ProgramFolder%
    Add_Shortcut,StartMenu,Security\%ProgramTitle%,%PE_Programs%\%ProgramFolder%\%ProgramEXE%,%ProgramTitle%
    
    
    regards,
    Homes32

  • pscEx likes this

#7 MasterG

MasterG
  • Members
  • 8 posts
  •  
    Greece

Posted 12 May 2014 - 07:09 AM

Thank you for your help.
I got Homes32 script to work. I could not get pscEX to work, it would not detect the version.
This is the script that works, using 2 folders, one x86 and one x64.
Tested both with 32bit windows 8.1 and 64bit. Thank you very much for your help.
 
[main]
Title=NTPWEdit
Description=Removes passwords
Selected=True
Level=5
Version=1
// [url=http://cdslow.webhost.ru/en/ntpwedit/]http://cdslow.webhost.ru/en/ntpwedit/[/url]
 
[variables]
%ProgramTitle%=NTPWEdit
%ProgramEXE%=NTPWEdit.exe
%ProgramFolder%=NTPWEdit
 
[process]
CopyProgram,%ScriptDir%\%SourceArch%
Add_Shortcut,StartMenu,Security\%ProgramTitle%,%PE_Programs%\%ProgramFolder%\%ProgramEXE%,%ProgramTitle%





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users