jbennett Posted November 12, 2008 Share Posted November 12, 2008 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 More sharing options...
Valuater Posted November 12, 2008 Share Posted November 12, 2008 Maybe.... _RunCMD("This is my title", "notepad.exe") Func _RunCMD($title, $prog) Run(@ComSpec & " /K title "&$title&"|"&$prog, @ScriptDir, @SW_MINIMIZE) EndFunc 8) Link to comment Share on other sites More sharing options...
jbennett Posted November 12, 2008 Author Share Posted November 12, 2008 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 More sharing options...
Valuater Posted November 12, 2008 Share Posted November 12, 2008 Take a better look, you did not use this correctly @ComSpec & " /K title "&$title&"|"&$prog, @ScriptDir, @SW_MINIMIZE 8) Link to comment Share on other sites More sharing options...
PsaltyDS Posted November 12, 2008 Share Posted November 12, 2008 (edited) 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' ) 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 November 12, 2008 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 More sharing options...
Valuater Posted November 12, 2008 Share Posted November 12, 2008 Missing at least one ampersand: At least, come-on Salty, your better than that! 8) Link to comment Share on other sites More sharing options...
PsaltyDS Posted November 12, 2008 Share Posted November 12, 2008 (edited) 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) Edited November 12, 2008 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 More sharing options...
jbennett Posted November 13, 2008 Author Share Posted November 13, 2008 (edited) 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 November 13, 2008 by jbennett Link to comment Share on other sites More sharing options...
PsaltyDS Posted November 13, 2008 Share Posted November 13, 2008 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. 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 More sharing options...
jbennett Posted November 13, 2008 Author Share Posted November 13, 2008 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 More sharing options...
PsaltyDS Posted November 13, 2008 Share Posted November 13, 2008 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 "*" & " ". 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now