Avatar of vikasbapat
vikasbapat asked on


Hi All
This command works fine from the command line:

C:\>type "C:\VisualSS\SQLCode\R-18_SQLEXPRESS\emp\RunLog5-29-2008 1-00-46 PM.Log" >> "C:\VisualSS\SQLCode\R-18_SQLEXPRESS\emp\RunScriptLog5-29-2008 1-00-46 PM.Log"

But the same command when i run with following script give VBScript compilation error  

' ********************************************
Option Explicit
Dim WshShell
Set WshShell = CreateObject("WScript.Shell")
WshShell.Run "command.com /k " & type "C:\VisualSS\SQLCode\R-18_SQLEXPRESS\emp\RunLog5-29-2008 1-00-46 PM.Log" >> "C:\VisualSS\SQLCode\R-18_SQLEXPRESS\emp\RunScriptLog5-29-2008 1-00-46 PM.Log" 'run DOS commands
Set WshShell = Nothing
I don't know what is going wrong. I want to copy the contain

"C:\VisualSS\SQLCode\R-18_SQLEXPRESS\emp\RunLog5-29-2008 1-00-46 PM.Log"  


"C:\VisualSS\SQLCode\R-18_SQLEXPRESS\emp\RunScriptLog5-29-2008 1-00-46 PM.Log"

Thank in Advanced
ProgrammingASPVB Script

Avatar of undefined
Last Comment

8/22/2022 - Mon

Try changing your wshShell line to this:
WshShell.Run "command.com /k " & "type ""C:\VisualSS\SQLCode\R-18_SQLEXPRESS\emp\RunLog5-29-2008 1-00-46 PM.Log"" >> ""C:\VisualSS\SQLCode\R-18_SQLEXPRESS\emp\RunScriptLog5-29-2008 1-00-46 PM.Log""" 'run DOS commands

Open in new window


try changing \ to \\ every where

C:\\VisualSS\\SQLCode\\R-18_SQLEXPRESS\\emp\\RunLog5-29-2008 1-00-46 PM.Log

C:\\VisualSS\\SQLCode\\R-18_SQLEXPRESS\\emp\\RunScriptLog5-29-2008 1-00-46 PM.Log

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question

The problem is partly spaces in the filenames/paths - they need to be quoted in a DOS prompt.

The attached code also hides the extra command window, and wait until the command has completed before returning to the calling script.
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes

It working fine when i am  hard code  the:

WshShell.Run "cmd /c type ""C:\VisualSS\SQLCode\R-18_SQLEXPRESS\emp\RunLog5-29-2008 1-00-46 PM.Log"" >> ""C:\VisualSS\SQLCode\R-18_SQLEXPRESS\emp\RunScriptLog5-29-2008 1-00-46 PM.Log""", 0, true 'run DOS commands

But when i  change hard coded path i.e

C:\VisualSS\SQLCode\R-18_SQLEXPRESS\emp\RunLog5-29-2008 1-00-46 PM.Log

with veriable file1 where file1 store same path.

i need to use veriable instead of hard code the path.

dim file1,file2
file1  'Souracepath
file1  'Destinationpath

i change it with But not woking

WshShell.Run "cmd /c type ""+file1+"" >> "" +file2+""", 0, true 'run DOS commands


Quotes within strings need to be DOUBLE-quoted.
WshShell.Run "cmd /c type """ & file1 & """ >> """ & file2 & """",0, true

Open in new window


I try this it  is not going any error.
But not copy THE contain of filepath1 INTO  filepath2.
I CHECK BY giving messages THEN
      Name                                                 SIZE
      filepath1 = RunLog6-2-2008 2-59-18 PM.log            7 KB
      filepath2 = RunScriptLog6-2-2008 2-59-18 PM.log           1 KB

I Don't know what is going wrong . plz suggest the solutions.


msgbox filepath1
msgbox filepath2

WshShell.Run "cmd /c type """ & filepath1 & """ >> """ & filepath2 & """",0, true

Set WshShell = NOTHING


Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.