Curtiss W. Posted August 17, 2006 Share Posted August 17, 2006 I have been write batch files for years but now its time to stright writeing code using a scripting. Auto It was suggested. I have been playing with it today and wrote a few simple things just to get started. But one thing is just going over my head. I need to use the system drive variable since we have machines were C: is not always the system drive. I can get the variable using envget and can even get it to dispaly in a message box but when I try to use it to run something it does not work. This works fine. RunWait ("test.bat" , "C:\Documents and Settings\user\Desktop\autoit-temp") but I need to replace C: with a variable Any help would be great. Curtiss W. Link to comment Share on other sites More sharing options...
NELyon Posted August 17, 2006 Share Posted August 17, 2006 RunWait("test.bat", @HomeDrive &"\Documents......") Link to comment Share on other sites More sharing options...
Curtiss W. Posted August 17, 2006 Author Share Posted August 17, 2006 RunWait("test.bat", @HomeDrive &"\Documents......") Ok I saw that and just assumed that that would be the variable that I use now on a AD network. That must be the differance between @HomeDrive and @HomeShare. Thanks! Curtiss W. Link to comment Share on other sites More sharing options...
blademonkey Posted August 17, 2006 Share Posted August 17, 2006 Ok I saw that and just assumed that that would be the variable that I use now on a AD network. That must be the differance between @HomeDrive and @HomeShare.Thanks!Curtiss W.WElcome to the forums Curtiss.Check out the macro reference in the help file. it's by far one of the best help files i've ever usedanyway all of the system macros @something are listed in there under Macro reference. ---"Educate the Mind, Make Savage the Body" -Mao Tse Tung Link to comment Share on other sites More sharing options...
Curtiss W. Posted August 17, 2006 Author Share Posted August 17, 2006 WElcome to the forums Curtiss.Check out the macro reference in the help file. it's by far one of the best help files i've ever usedanyway all of the system macros @something are listed in there under Macro reference.Ok can you use a variable when you copy a file to change the name? Can you do it on the fly or do you have to rename the file first and then copy it? See Below.FileCopy ( @homedrive &"\Documents and Settings\user\Desktop\autoit-temp\a\test.bat" , @homedrive &"\Documents and Settings\user\Desktop\autoit-temp\b\ @computername & -test.bat", 9)In this case when the file is copied from floder a to folder b I need to add the computer name to the front of the file name. so it starts off as test.bat but need to end up as %computer%-test.bat Link to comment Share on other sites More sharing options...
JSThePatriot Posted August 17, 2006 Share Posted August 17, 2006 Ok can you use a variable when you copy a file to change the name? Can you do it on the fly or do you have to rename the file first and then copy it? See Below. FileCopy ( @homedrive &"\Documents and Settings\user\Desktop\autoit-temp\a\test.bat" , @homedrive &"\Documents and Settings\user\Desktop\autoit-temp\b\ @computername & -test.bat", 9) In this case when the file is copied from floder a to folder b I need to add the computer name to the front of the file name. so it starts off as test.bat but need to end up as %computer%-test.bat Yes you can use a variable. What you are missing on the second is the proper placement of the quotes. You have it correct on your first statement, but the second one needs a little work. Also welcome to the forums! We are happy to have you as a member. One quick note would be that you can either use [ autoit ] [ /autoit ] or [ code ] [ /code ] (without the spaces) to put your code into. FileCopy(@HomeDrive & "\Documents and Settings\user\Desktop\autoit-temp\a\test.bat", @HomeDrive & "\Documents and Settings\user\Desktop\autoit-temp\b\" & @ComputerName & "-test.bat", 9) I hope that helps. Notice I stopped the quotes added the variable using the ampersand (&) and then resumed the quotes to make it finish. I hope the above helps some, JS AutoIt Links File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out. ComputerGetInfo UDF's Updated! 11-23-2006 External Links Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more) Link to comment Share on other sites More sharing options...
MHz Posted August 17, 2006 Share Posted August 17, 2006 (edited) Perhaps the @DesktopDir macro may suit better. FileCopy(@DesktopDir & "\autoit-temp\a\test.bat", @DesktopDir & "\autoit-temp\b\" & @ComputerName & "-test.bat", 9) oÝ÷ ØéíéبÒÊË^:â½ä²²×¦¸¯z+-çk÷°êÞ¶ÊË^Ø«yËh¯*Þ²'^±©Ý¶¢g®+ÞËayÚâ½ëajÛaxz&xöØ«yËh¯*Þ²'^°Ú+©eÊƦyÚâ½çèº-»q©ÛyÈZÂ+ajǶ)àu¢Ú0²Çº¨ºÈ§Iïëjx^çyÖ®¶s`¢b33c·77FVÖG&fRÒVçdvWBb33·77FVÖG&fRb33² Edited August 17, 2006 by MHz Link to comment Share on other sites More sharing options...
JSThePatriot Posted August 17, 2006 Share Posted August 17, 2006 @MHz I was thinking the same thing, but that was really early this morning. JS AutoIt Links File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out. ComputerGetInfo UDF's Updated! 11-23-2006 External Links Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more) Link to comment Share on other sites More sharing options...
Curtiss W. Posted August 19, 2006 Author Share Posted August 19, 2006 (edited) Yes you can use a variable. What you are missing on the second is the proper placement of the quotes. You have it correct on your first statement, but the second one needs a little work. Also welcome to the forums! We are happy to have you as a member. One quick note would be that you can either use [ autoit ] [ /autoit ] or [ code ] [ /code ] (without the spaces) to put your code into. FileCopy(@HomeDrive & "\Documents and Settings\user\Desktop\autoit-temp\a\test.bat", @HomeDrive & "\Documents and Settings\user\Desktop\autoit-temp\b\" & @ComputerName & "-test.bat", 9) I hope that helps. Notice I stopped the quotes added the variable using the ampersand (&) and then resumed the quotes to make it finish. I hope the above helps some, JS Ok that helps alot with this type of scripting you are using "&" insted of "%" that helps. But on the system drive part I did try that once and I could get the program to dispaly the variable but I could not us it in a line of code will try it again. Also it looks like @homeDrive will not work once the computer is on a network. Is there a variable in AutoIt that replaces %systemdrive% Thanks again. Curtiss w. Edited August 19, 2006 by Curtiss W. Link to comment Share on other sites More sharing options...
MHz Posted August 19, 2006 Share Posted August 19, 2006 Is there a variable in AutoIt that replaces %systemdrive%Look at my previous post for $systemdrive = .... Link to comment Share on other sites More sharing options...
JSThePatriot Posted August 19, 2006 Share Posted August 19, 2006 Or would @SystemDir be able to get the "system drive"? I will have to test that. JS AutoIt Links File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out. ComputerGetInfo UDF's Updated! 11-23-2006 External Links Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more) Link to comment Share on other sites More sharing options...
Danny35d Posted August 19, 2006 Share Posted August 19, 2006 Or would @SystemDir be able to get the "system drive"? I will have to test that. JSActually @SYSTEMDIR = Path of System32 folder and not the drive letter (c:\windows\system32 or c:\winnt\system32) @Curtiss W. Like MHz mention on Post 7 $systemdrive = EnvGet('systemdrive') FileCopy($systemdrive & "\Documents and Settings\user\Desktop\autoit-temp\a\test.bat", $systemdrive & "\Documents and Settings\user\Desktop\autoit-temp\b\" & @ComputerName & "-test.bat", 9) AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line Link to comment Share on other sites More sharing options...
JSThePatriot Posted August 19, 2006 Share Posted August 19, 2006 Actually @SYSTEMDIR = Path of System32 folder and not the drive letter (c:\windows\system32 or c:\winnt\system32) @Curtiss W. Like MHz mention on Post 7 $systemdrive = EnvGet('systemdrive') FileCopy($systemdrive & "\Documents and Settings\user\Desktop\autoit-temp\a\test.bat", $systemdrive & "\Documents and Settings\user\Desktop\autoit-temp\b\" & @ComputerName & "-test.bat", 9) Yes I know it gives the path to the System32 folder, but it does use the System Directory in that path. I was saying it could be solved for the System Directory. JS AutoIt Links File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out. ComputerGetInfo UDF's Updated! 11-23-2006 External Links Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more) Link to comment Share on other sites More sharing options...
Danny35d Posted August 19, 2006 Share Posted August 19, 2006 Yes I know it gives the path to the System32 folder, but it does use the System Directory in that path. I was saying it could be solved for the System Directory.JSAah, sorry that I miss understand your point but, English is my second language... AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line Link to comment Share on other sites More sharing options...
JSThePatriot Posted August 20, 2006 Share Posted August 20, 2006 Aah, sorry that I miss understand your point but, English is my second language... Well... you have pretty decent English skills for a second language. GJ.Lata,JS AutoIt Links File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out. ComputerGetInfo UDF's Updated! 11-23-2006 External Links Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more) 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