Jump to content
Sign in to follow this  

trouble with @ComSpec and variables

Recommended Posts


Let me start by saying I love Autoit. It's so easy to work with usually. I'm not a programmer. When I was in high school, advanced computer programming taught Basic. I've started working with Autoit recently and so far have made a couple of cool programs. I work in computer repair, and business is great. We have several Newbies, I need to write a simple script to use robocopy to copy files from one location to another with predetermined swithces. Robocopy can run as a backup process and copy files even if the newbies forget to take permission of the folder to be copied. I have my GUI that returns selected locations, but when I try to use my variables with comspec I always get an error in command prompt "the system cannot find the path specified. I'm sure it's a simple syntax error, but I need a little help.

RunWait(@ComSpec & " /k " & '"robocopy.exe" & $src & $dest "\*.* /FP /S /E /COPY:DAT /ZB /R:0 /W:0"',"",@SW_SHOW)

Any assistance would be greatly appreciated.

Thanks in advance.

Share this post

Link to post
Share on other sites

Welcome to the forum ajblandford, :mellow:

Try showing your CMD string in a messagebox to see if it looks correct if you have issues. Take note in the help file under Run() / RunWait() for the remark with paths with spaces need to be enclosed in quotation marks.

; Try showing the CMD string in a messagebox to see result
$src = 'c:\path\with\white space'
$dest = 'c:\path\with some more\white space'
$cmd = '"' & @ComSpec & '" /k robocopy.exe "' & $src & '" "' & $dest & '\*.*" /FP /S /E /COPY:DAT /ZB /R:0 /W:0'
MsgBox(0, 'CMD string to use', $cmd)

; Solution to try
;~ RunWait('"' & @ComSpec & '" /k robocopy.exe "' & $src & '" "' & $dest & '\*.*" /FP /S /E /COPY:DAT /ZB /R:0 /W:0', "", @SW_SHOW)

The messagebox above shows my attempt at the command needed. Hopefully is OK.

The RunWait() line is commented for safety. Uncomment for testing. I would test on some *copies* of folders first.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.