Sign in to follow this  
Followers 0
microbious

how to combine $vars and @comspec commands ?

6 posts in this topic

i am working on loader for my self that would save users data into saved folder and restore it from where it was backed up if nothing was there or even if it was it will overwrite it.

I need to use windows XCOPY because to copy files modified only recently will take more then one line of coding using autoit, instead i can do it with single line using @comspec xcopy command but i dont know how to combine commands used by @comSpec and $var's i used to get userprofile folder name

Here is what i have so far. This will only backup for now.

$dir = (@UserProfileDir & "\AppData\Local\Mozilla\Firefox\Profiles\")
$UserFolderName = _FileListToArray (@UserProfileDir & "\AppData\Local\Mozilla\Firefox\Profiles") ;list folders in this directory to array
$name =  _ArrayToString ($UserFolderName,@TAB,1) ;get name of second entry in the array list without displaying the array
$copy = DirCopy (@UserProfileDir & "\AppData\Local\Mozilla\Firefox\Profiles\" & $name,"saved",1)

What i have in mind is the following.

$dir = (@UserProfileDir & "\AppData\Local\Mozilla\Firefox\Profiles\")
$UserFolderName = _FileListToArray (@UserProfileDir & "\AppData\Local\Mozilla\Firefox\Profiles") ;list folders in this directory to array
$name =  _ArrayToString ($UserFolderName,@TAB,1) ;get name of second entry in the array list without displaying the array
$copy = RunWait (@ComSpec & 'c/ xcopy /E/D ' & $dir & $name & 'Saved /Y')

where c/ xcopy /E/D Saved /Y is the actual command that @comspec or CMD would understand.

Problem is that i cant figure out how to help @comspec or CMD to understand $vars given by autori so that CMD would understand where to copy files from and to.

Can you guys give me an example how would i copy file using xcopy so it would work with autoit $var's as to point where to copy those files from ?

Share this post


Link to post
Share on other sites



How about "/c" vice "c/":

$copy = RunWait (@ComSpec & '/c xcopy /E/D/Y ' & $dir & $name & 'Saved')

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

How about "/c" vice "c/":

$copy = RunWait (@ComSpec & '/c xcopy /E/D/Y ' & $dir & $name & 'Saved')

:)

/c is a console switch for CMD

Doesnt work

Folder contents needs to be copied into script directory "saved /Y" folder where Y stands for overwrite switch but its not copied anywhere.

In fact i dont even see CMD console window poping up when code executed.

Edited by almostnotstupid

Share this post


Link to post
Share on other sites

to "see" the command window use

RunWait (@ComSpec & '/k ...

Also, I think there is a spaced needed here..

... & ' Saved /y')

I am not sure on this

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

Hi,

Try this...

$source = '"C:\Documents and Settings\User\Desktop\test"'
$destination = '"C:\Documents and Settings\User\Desktop\test2"'
Run(@ComSpec & " /k xcopy "&$source&" "&$destination&" /E/D /Y") ; you can change /k to /c later

It's a good pratice to put file path inside quotes, it's a must with path contains white space


Hi ;)

Share this post


Link to post
Share on other sites

thank you all guys it totally worked.

I wish autoit had all xcopy features built into filecopy dircopy that would be allot easier to deal with.

What i did and could do wrong was

RunWait (@ComSpec & '/k xcopy /E/D' & $dir & $name & 'Saved /Y')

instead it had to be

RunWait (@ComSpec & ' /k xcopy /E/D ' & $dir & $name & ' Saved /Y')

with space before /K and after /D and space before Saved

I can get confused with all those sometimes.

Thanks to all of u guys for help

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  
Followers 0