Jump to content
Sign in to follow this  
bobheart

What do I have wrong here ?

Recommended Posts

bobheart

DirCreate("C:\Mydosbackups")
Run(@ComSpec & " /C:\WINDOWS\*.ini, ""C:\Mydosbackups,"")
Run(@ComSpec & " /C:\WINDOWS\*.bat, ""C:\Mydosbackups,"")

---------------------------
AutoIt Error
---------------------------
Line 3  (File "E:\Programs\AutoIt3\Examples\june7\copy.au3"):

Run(@ComSpec & "" /C:\WINDOWS\*.ini, ""C:\Mydosbackups,"")
Run(@ComSpec & "" /C^ ERROR

Error: Unable to parse line.

Share this post


Link to post
Share on other sites
pekster

To illustrate what is wrong, I will color your code. Strings in blue, with the enclosed quotation marks in green and incraesed in size.

DirCreate("C:\Mydosbackups")

Run(@ComSpec & " /C:\WINDOWS\*.ini, ""C:\Mydosbackups,"")

Run(@ComSpec & " /C:\WINDOWS\*.bat, ""C:\Mydosbackups,"")

As should be clear now, you have two strings just sitting next to each other on several occations. Try reformatting your strings so that it ends up being a valid command. Make sure commas end up outside strings if you want to use a 2nd paramater for functions, and that strings you wish to join are properly joined with the & symbol.

Bah, it's late, and I can't think. Several words replaced, and the syntax highlighting fixed in this edit.

Edited by pekster

[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

Share this post


Link to post
Share on other sites
bobheart

Ok No errors now but it won't copy the ini files ?and the dos box won't hide .

DirCreate("C:\Mydosbackups2")
Run(@ComSpec & " /C:\WINDOWS\*.ini  C:\Mydosbackups2 ,@SW_HIDE")
Edited by bobheart

Share this post


Link to post
Share on other sites
pekster

Syntax for the Run function with the Comm Interperter is as follows (taken from the helpfile with highlighting):

Run( @ComSpec & "/c " & "CommandName", "Workingdir", <FLAG>)

You appear to have used the /C, but didn't use a space after it. In addition, the following is not a valid DOS command: " /C:\WINDOWS\*.ini C:\Mydosbackups2 ,@SW_HIDE", which is what you told it to run.

Perhaps you mean:

Run( @ComSpec & "/c " & "copy C:\WINDOWS\*.ini C:\Mydosbackups2", "", @SW_HIDE)

Note: that code is the same as the one below. However, you must make sure there is a space after the /c part of the string, and the rest of your DOS command, otherwise you'll have this problem.

Run( @ComSpec & "/c copy C:\WINDOWS\*.ini C:\Mydosbackups2", "", @SW_HIDE)

Edited to add in my close parentheses and fix a spelling error

Edited again to add in the code at the bottom I referanced but forgot to include

Edited by pekster

[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

Share this post


Link to post
Share on other sites
bobheart

I'm not sure I'm looking at the same help file as all I found was this .

value of %comspec%, the SPECified secondary COMmand interpreter;
primarly for command line uses, e.g.  Run(@ComSpec & " /k help | more")

So thats what I was going by to do it .

Thank you for the help .

Just ran what you had and got this ?

---------------------------

AutoIt Error

---------------------------

Line 2 (File "E:\Programs\AutoIt3\Examples\june7\copy.au3"):

Run( @ComSpec & "/c copy C:\WINDOWS\*.ini C:\Mydosbackups2", "", @SW_HIDE)

Error: Unable to execute the external program.

The system cannot find the path specified.

---------------------------

OK

---------------------------

Edited by bobheart

Share this post


Link to post
Share on other sites
pekster

I'm not sure I'm looking at the same help file as all I found was this .

Look at the Run function, found in the AutoIt: Function Referance: Process Management: Run section. See also: RunWait in the same path.

[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

Share this post


Link to post
Share on other sites
pekster

Just ran what you had and got this ?

Whopsie. You need a space before the /c part of the string, otherwise it runs into the location of the Command Interperter. so the first string should read quotation mark + space + slash + 'c' + quotation mark.

[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

Share this post


Link to post
Share on other sites
bobheart

That was it , runs fine now . thank you .

Can I add like dos and do *.ini *.bat *.dat etc ? so it can be all on one line .

Share this post


Link to post
Share on other sites
bobheart

Well that didn't work . the way I got it to work was doing like this .

DirCreate("C:\Mydosbackups2")
Run( @ComSpec & " /c copy C:\WINDOWS\*.ini C:\Mydosbackups2", "", @SW_HIDE)
Run( @ComSpec & " /c copy C:\WINDOWS\*.dat C:\Mydosbackups2", "", @SW_HIDE)
Run( @ComSpec & " /c copy C:\WINDOWS\*.bat C:\Mydosbackups2", "", @SW_HIDE)
Run( @ComSpec & " /c copy C:\*.ini C:\Mydosbackups2", "", @SW_HIDE)
Run( @ComSpec & " /c copy C:\*.bat C:\Mydosbackups2", "", @SW_HIDE)
Run( @ComSpec & " /c copy C:\*.dat C:\Mydosbackups2", "", @SW_HIDE)

Is there a better way ?

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.