Solved

script needed

Posted on 2013-11-26
8
343 Views
Last Modified: 2013-11-28
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 ?
0
Comment
Question by:Eprs_Admin
8 Comments
 
LVL 34

Expert Comment

by:Dan Craciun
ID: 39677897
Check if the folder Program Files (x86) exists.
If it does, copy the x64 version, if not, go for the x86 one

HTH,
Dan
0
 

Author Comment

by:Eprs_Admin
ID: 39678095
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
0
 
LVL 34

Assisted Solution

by:Dan Craciun
Dan Craciun earned 200 total points
ID: 39678145
$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.
0
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 

Author Comment

by:Eprs_Admin
ID: 39678179
I have seen, this is powershell.
How to do this in DOS as batch file?
Because the clients don´t have PS installed
0
 
LVL 34

Accepted Solution

by:
Dan Craciun earned 200 total points
ID: 39678213
What OS are your clients on? Powershell is installed on Windows 7 by default.
0
 
LVL 14

Assisted Solution

by:ThomasMcA2
ThomasMcA2 earned 100 total points
ID: 39678456
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

0
 
LVL 53

Assisted Solution

by:Bill Prew
Bill Prew earned 100 total points
ID: 39678457
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

~bp
0
 
LVL 43

Assisted Solution

by:Steve Knight
Steve Knight earned 100 total points
ID: 39678801
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....  

Steve
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If like me you are one who spends a lot of time working and scripting with cmd.exe, sometimes it is handy to be able to quickly view a calendar for a given month and year. This script will quickly do just that!  Save the code posted below to a .bat …
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

825 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question