• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 353
  • Last Modified:

script needed

Hi Experts,

I need a script to copy two files from a share to my clients.
The files needed to be copied to the programfiles folder.
Before the copy, the script has to check if its a x86 or x64 system.

Any ideas ?
5 Solutions
Dan CraciunIT ConsultantCommented:
Check if the folder Program Files (x86) exists.
If it does, copy the x64 version, if not, go for the x86 one

Eprs_AdminSystem ArchitectAuthor Commented:
I need a script for it.
The script should check it like:

wmic os get architecture

and the result should of it should decide to install into folder x64 or x86.

How to do this via batch script
Dan CraciunIT ConsultantCommented:
$serverPath = "\\path\to\server"
$localPath = "X:\local\path"

if ((Get-WmiObject Win32_OperatingSystem).OSArchitecture -eq "64-bit") {
  Copy-Item $serverPath -Destination $localPath"\x64\"
else Copy-Item $serverPath -Destination $localPath"\x86\"

Not tested, but should get you started.
Train for your Pen Testing Engineer Certification

Enroll today in this bundle of courses to gain experience in the logistics of pen testing, Linux fundamentals, vulnerability assessments, detecting live systems, and more! This series, valued at $3,000, is free for Premium members, Team Accounts, and Qualified Experts.

Eprs_AdminSystem ArchitectAuthor Commented:
I have seen, this is powershell.
How to do this in DOS as batch file?
Because the clients donĀ“t have PS installed
Dan CraciunIT ConsultantCommented:
What OS are your clients on? Powershell is installed on Windows 7 by default.
Try this:

@echo off

set serverPath = "\\path\to\server"

if exist "C:\Program Files (x86)" (
   set localPath = "C:\Program Files (x86)"
) else (
   set localPath = "C:\Program Files"

copy %serverPath% %localPath%

Open in new window

Bill PrewCommented:
Give this BAT a try, updating the files to copy.

@echo off

for /f "skip=2 tokens=2 delims=," %%A in ('wmic os get osarchitecture^,version /format:csv') do (
  if "%%A" EQU "64-bit" (
    set DestDir=C:\Program Files (x86)
  ) else (
    set DestDir=C:\Program Files

copy "\\server\share\file1.txt" "%DestDir%"
copy "\\server\share\file2.txt" "%DestDir%"

Open in new window

Steve KnightIT ConsultancyCommented:
BTW is this a domain environment, have you tried out group policy preferences, you can easily target x64 and x86 differently and push down files,registry, apps etc....  

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now