Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Xcopy in VBS

Posted on 2009-02-18
6
Medium Priority
?
765 Views
Last Modified: 2013-11-25
I need to turn the following bat logon script into a VBS instead. can someone tell me how to do this?

@echo off
xcopy "\\xxx.local\NETLOGON\Signatures\%USERNAME%\*.htm" "%USERPROFILE%\Application Data\Microsoft\Signatures" /Y /I /Q
xcopy "\\xxx.local\NETLOGON\Signatures\%USERNAME%\*.jpg" "%USERPROFILE%\Application Data\Microsoft\Signatures" /Y /I /Q


This also may need to be different for vista users.
0
Comment
Question by:DannyIce
  • 2
4 Comments
 
LVL 67

Accepted Solution

by:
sirbounty earned 2000 total points
ID: 23677262
This should do it...
Dim objShell : Set objShell = CreateObject("Wscript.Shell")
 
objShell.Run "xcopy " & chr(34) & "\\xxx.local\NETLOGON\Signatures\%USERNAME%\*.htm" & chr(34) & " " & chr(34) &  "%USERPROFILE%\Application Data\Microsoft\Signatures" & chr(34) & " /Y /I /Q"
objShell.RUn "xcopy " & chr(34) & "\\xxx.local\NETLOGON\Signatures\%USERNAME%\*.jpg" & chr(34) & " " & chr(34) &  "%USERPROFILE%\Application Data\Microsoft\Signatures" & chr(34) & " /Y /I /Q"

Open in new window

0
 
LVL 65

Expert Comment

by:RobSampson
ID: 23677458
Hi, you can try this too, in case the %USERNAME% and %USERPROFILE% values don't expand for you.

Regards,

Rob.
Dim objShell : Set objShell = CreateObject("Wscript.Shell")
strUserName = objShell.ExpandEnvironmentStrings("%USERNAME%")
strUserProfile = objShell.ExpandEnvironmentStrings("%USERPROFILE%")
objShell.Run "xcopy " & chr(34) & "\\xxx.local\NETLOGON\Signatures\" & strUserName & "\*.htm" & chr(34) & " " & chr(34) & strUserProfile & "\Application Data\Microsoft\Signatures" & chr(34) & " /Y /I /Q"
objShell.Run "xcopy " & chr(34) & "\\xxx.local\NETLOGON\Signatures\" & strUserName & "\*.jpg" & chr(34) & " " & chr(34) & strUserProfile & "\Application Data\Microsoft\Signatures" & chr(34) & " /Y /I /Q"

Open in new window

0
 

Author Closing Comment

by:DannyIce
ID: 31548215
Excellent - good man!
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 23683896
Happy to help - thanx for the grade! :^)
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

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

Question has a verified solution.

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

A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…

564 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