Jump to content

Issue with adding @SW_MINIMIZE and remarks to RunWait cmd


jbennett
 Share

Recommended Posts

Hi,

Got a bit of an issue and wondering if anyone could help me out.

I've got a piece of code that runs a cmd window and i'm wondering how I can run this as minimized and add a few remarks to the cmd window before proceeding so that if the user maximizes the window they can see what the cmd window is all about.

My code is

RunWait(@ComSpec & " /c " & "xcopy " & $working_location  & "*" & "  " & $backup_location & "\" & @computername & " " & ' /D /E /C /R /H /I /K /Y /S')

Thanks :-)

p.s. $working_location and $backup_location is just something i'm getting from an .ini file.

Link to comment
Share on other sites

Thanks for your reply.

I'm really struggling to get this working though :-(

I've attempting to get it working with the following code but this doesn't work and I have also been unable to get the @SW_MINIMIZE to work but removed it for the time being

_Test("hello")

Func _Test($title)
RunWait(@ComSpec & " /k title "&$title", xcopy " & $working_location  & "*" & "  " & $backup_location & "\" & @computername & " " & ' /D /E /C /R /H /I /K /Y /S' )
endfunc

Any ideas what I may be doing wrong?

Many thanks

Link to comment
Share on other sites

Thanks for your reply.

I'm really struggling to get this working though :-(

I've attempting to get it working with the following code but this doesn't work and I have also been unable to get the @SW_MINIMIZE to work but removed it for the time being

_Test("hello")

Func _Test($title)
RunWait(@ComSpec & " /k title "&$title", xcopy " & $working_location  & "*" & "  " & $backup_location & "\" & @computername & " " & ' /D /E /C /R /H /I /K /Y /S' )
endfunc

Any ideas what I may be doing wrong?

Many thanks

Missing at least one ampersand:

RunWait(@ComSpec & " /k title "& $title & ", xcopy " & $working_location & "*" & " " & $backup_location & "\" & @computername & " " & ' /D /E /C /R /H /I /K /Y /S' )

:mellow:

P.S. If $backup_location contains any spaces, you might also want to enclose that parameter in double quotes. This is easier to keep straight if you use single quotes to enclose the strings for AutoIt, then put the double quotes inside them:

RunWait(@ComSpec & ' /k title ' & $title & ', xcopy ' & $working_location  & '*  "' & $backup_location & '"\' & @computername & '  /D /E /C /R /H /I /K /Y /S' )

:(

Edited by PsaltyDS
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
Link to comment
Share on other sites

At least, come-on Salty, your better than that!

:(

8)

How about at least 3 ampersands? Because in addition, "title" is a separate command from xcopy, if you want to execute both with one string you need "&&" between them. Demo:
$title = "Test Title"
Run(@ComSpec & ' /k title ' & $title & '&& xcopy.exe /?', @TempDir)

:mellow:

Edited by PsaltyDS
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
Link to comment
Share on other sites

Hiya,

Thanks for the ideas, really helped :-)

I've got one question though, from my working code below how would I add something within the cmd window itself.

e.g. Backup running. Please wait....

Thanks very much

_xcopy("Please Wait")

Func _xcopy($title)
RunWait(@ComSpec & ' /k title ' & $title & '&& xcopy ' & $working_location  & "*" & "  " & $backup_location & "\" & @computername & " " & ' /D /E /C /R /H /I /K /Y /S')
EndFunc

EDIT

----

The cmd window doesn't close after it has copied files neither, hmmmm?

Edited by jbennett
Link to comment
Share on other sites

Hiya,

Thanks for the ideas, really helped :-)

I've got one question though, from my working code below how would I add something within the cmd window itself.

e.g. Backup running. Please wait....

Thanks very much

_xcopy("Please Wait")

Func _xcopy($title)
RunWait(@ComSpec & ' /k title ' & $title & '&& xcopy ' & $working_location  & "*" & "  " & $backup_location & "\" & @computername & " " & ' /D /E /C /R /H /I /K /Y /S')
EndFunc
Try this example with some echos:
Run(@ComSpec & " /k echo Listing executables.  Please wait... && echo. && " & _
        "DIR *.exe > ExeList.txt && echo. && echo Done. Showing list: && echo. && TYPE ExeList.txt", @TempDir)

EDIT

----

The cmd window doesn't close after it has copied files neither, hmmmm?

That is because of the "/k" switch. If you want to run the command(s) and then close the shell use the more common "/c". The "/k" is used in the demos so you can see the results.

:mellow:

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
Link to comment
Share on other sites

Thanks for that.

I've almost worked it out now. The only problem is my title now displays in the cmd window instead?.

Any ideas what i'm missing?. Many thanks

Func _xcopy($title)
RunWait(@ComSpec & ' /C title && ECHO Please wait... '& _ 
$title & '&& xcopy ' & $working_location  & "*" & "  " _ 
& $backup_location & "\" & @computername & " " & ' /D /E /C /R /H /I /K /Y /S')
EndFunc

:-)

Link to comment
Share on other sites

Thanks for that.

I've almost worked it out now. The only problem is my title now displays in the cmd window instead?.

Any ideas what i'm missing?. Many thanks

Func _xcopy($title)
RunWait(@ComSpec & ' /C title && ECHO Please wait... '& _ 
$title & '&& xcopy ' & $working_location  & "*" & "  " _ 
& $backup_location & "\" & @computername & " " & ' /D /E /C /R /H /I /K /Y /S')
EndFunc

:-)

Maybe you meant this way:
RunWait(@ComSpec & ' /C title ' & $title & ' && ' & _
'ECHO Please wait... && ' & _ 
'xcopy ' & $working_location  & "*  " & $backup_location & "\" & @computername & " " & ' /D /E /C /R /H /I /K /Y /S')

BTW, there is no need to take two literal strings and append them together, just provide them straight up. Use "* " vice "*" & " ".

:mellow:

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
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...