We help IT Professionals succeed at work.

Xcopy in VBS

Medium Priority
869 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.
Comment
Watch Question

CERTIFIED EXPERT
Top Expert 2007
Commented:
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

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2014

Commented:
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

Author

Commented:
Excellent - good man!
CERTIFIED EXPERT
Top Expert 2007

Commented:
Happy to help - thanx for the grade! :^)
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.