?
Solved

script needed

Posted on 2013-11-26
8
Medium Priority
?
346 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 35

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 35

Assisted Solution

by:Dan Craciun
Dan Craciun earned 800 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
Certified OpenStack Administrator Course

We just refreshed our COA course based on the Newton exam.  With 14 labs, this course goes over the different OpenStack services that are part of the certification: Dashboard, Identity Service, Image Service, Networking, Compute, Object Storage, Block Storage, and Orchestration.

 

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 35

Accepted Solution

by:
Dan Craciun earned 800 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 400 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 57

Assisted Solution

by:Bill Prew
Bill Prew earned 400 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 400 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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

Batch, VBS, and scripts in general are incredibly useful for repetitive tasks.  Some tasks can take a while to complete and it can be annoying to check back only to discover that your script finished 5 minutes ago.  Some scripts may complete nearly …
Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
Suggested Courses

765 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