Sign in to follow this  
Followers 0
Curtiss W.

System variables

15 posts in this topic

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.

Share this post


Link to post
Share on other sites



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.

Share this post


Link to post
Share on other sites

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 used

anyway all of the system macros @something are listed in there under Macro reference.


---"Educate the Mind, Make Savage the Body" -Mao Tse Tung

Share this post


Link to post
Share on other sites

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 used

anyway 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

Share this post


Link to post
Share on other sites

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)

Share this post


Link to post
Share on other sites

#7 ·  Posted (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²

:P

Edited by MHz

Share this post


Link to post
Share on other sites

@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)

Share this post


Link to post
Share on other sites

#9 ·  Posted (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 by Curtiss W.

Share this post


Link to post
Share on other sites

Is there a variable in AutoIt that replaces %systemdrive%

Look at my previous post for $systemdrive = .... :P

Share this post


Link to post
Share on other sites

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)

Share this post


Link to post
Share on other sites

Or would @SystemDir be able to get the "system drive"? I will have to test that.

JS

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)

AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line

Share this post


Link to post
Share on other sites

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)

Share this post


Link to post
Share on other sites

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

Aah, sorry that I miss understand your point but, English is my second language... :P

AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line

Share this post


Link to post
Share on other sites

Aah, sorry that I miss understand your point but, English is my second language... :P

Well... you have pretty decent English skills for a second language. :nuke: 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)

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