S
S
sevafanasev2016-11-24 15:01:54
cmd/bat
sevafanasev, 2016-11-24 15:01:54

Where is the error in the script for copying a folder, depending on the bitness of the OS?

Good time!
The situation is as follows: it is necessary that the script, after its launch, copies a certain folder from the network path to the computer where it was launched.
Copying should take place in different directories, depending on the bit depth of the OS.
I didn’t come across writing scripts so often, that’s why the question arose. I posted my version, but unfortunately it doesn't work. The script can be used both in BAT and VBS, the main thing is that the essence of copying is unchanged.

@echo on
set old_dir="\\ws-it-18\etc\LibreOffice\extensions\"
set x64="C:\Program Files (x86)\LibreOffice 5\share\extensions\"
set x86="C:\Program Files\LibreOffice 5\share\extensions\"
set "osX=%PROCESSOR_ARCHITECTURE%"
if defined PROCESSOR_ARCHITEW6432 set "osX=AMD64"
if "%osX%"=="x86" (
  xcopy %old_dir% %x86%
) else (
  xcopy %old_dir% %x64%
)
exit /b

Thank you in advance!

Answer the question

In order to leave comments, you need to log in

3 answer(s)
C
Cool Admin, 2016-11-24
@sevafanasev

What if so?

@echo on
set old_dir="\\ws-it-18\etc\LibreOffice\extensions\"
set x64="C:\Program Files (x86)\LibreOffice 5\share\extensions\"
set x86="C:\Program Files\LibreOffice 5\share\extensions\"

IF %PROCESSOR_ARCHITECTURE% == x86 (
  IF %PROCESSOR_ARCHITEW6432% NOT DEFINED ( 
        xcopy %old_dir% %x86%
   ) else ( 
       xcopy %old_dir% %x64%
))
exit /b

I seem to have messed up with quotes. Check for yourself
Check I can’t sit on Nokia 3111

A
Andrew, 2016-11-24
@OLS

I have

IF %PROCESSOR_ARCHITECTURE% == AMD64 (
   echo AMD_64
   ) else ( 
   echo OTHER
))

works successfully

E
Evgeniy Dikevich, 2016-11-25
@tonyslark

If Powershell is suitable, then you can
switch ((Get-WmiObject Win32_Processor).DataWidth)
{
64 {$DPath = "C:\Program Files (x86)\..."}
32 {$DPath = "C:\Program Files \..."}
}
instead of ellipsis further your paths. The DPath variable stores your full path.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question