+ Reply to Thread
Results 1 to 6 of 6

running shell with variables

  1. #1
    Forum Contributor
    Join Date
    05-10-2011
    Location
    Budapest, Hungary
    MS-Off Ver
    Excel 2016
    Posts
    187

    running shell with variables

    Hi All,

    I need to run xcopy from shell, but I want loop over on a file list, so I need to add the actual file name to the xcopy command as a variable.
    Unfortunately I cannot figure out the right syntax.
    How should I modify this command to replace the file name with a variable?

    Shell "cmd /c xcopy /y c:\temp\myfiles* C:\Temp\Backup"

    Many thanks

  2. #2
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: running shell with variables

    Like this
    Please Login or Register  to view this content.
    if the destination is fixed?
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  3. #3
    Forum Contributor
    Join Date
    05-10-2011
    Location
    Budapest, Hungary
    MS-Off Ver
    Excel 2016
    Posts
    187

    Re: running shell with variables

    Yes, it is.

  4. #4
    Forum Contributor
    Join Date
    05-10-2011
    Location
    Budapest, Hungary
    MS-Off Ver
    Excel 2016
    Posts
    187

    Re: running shell with variables

    why " should be added 3 times?

  5. #5
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: running shell with variables

    If there are spaces in the path/file name, you need to enclose it in quotes, and quotes inside a quoted string in VBA need to be doubled up.

  6. #6
    Forum Contributor
    Join Date
    05-10-2011
    Location
    Budapest, Hungary
    MS-Off Ver
    Excel 2016
    Posts
    187

    Re: running shell with variables

    Thanks a lot for your help.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Chrome shell with variables?
    By y21leo in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-07-2017, 09:41 AM
  2. Running an Exe file through Shell
    By jdlc in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-23-2015, 09:19 AM
  3. [SOLVED] Macro to enter variables to Shell Command
    By ussenterprise in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-14-2013, 03:27 PM
  4. Shell - trouble with variables and quotes
    By brl8 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-30-2010, 12:01 PM
  5. Using macro to enter variables to Shell Command
    By Padre in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 10-12-2009, 05:06 PM
  6. [SOLVED] running commands from hte shell
    By Ruthless Dog in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-17-2005, 10:06 AM
  7. Pass variables value to Shell
    By wpw3 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-07-2005, 12:06 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1