dancer58 Posted August 24, 2007 Share Posted August 24, 2007 I'm sure this is very simple I am trying to do a dos command but it doesn't change Is %programfiles% in dos the same as @ProgramFilesDir in autoit ? $rc = _RunDos('set programfiles=e:\backups') MsgBox(0, "program files (should be e:\backups):", @ProgramFilesDir) "set programfiles=e:\backups" works in dos "changedirectorys.cmd" Thanks Link to comment Share on other sites More sharing options...
PsaltyDS Posted August 24, 2007 Share Posted August 24, 2007 I'm sure this is very simple I am trying to do a dos command but it doesn't changeIs %programfiles% in dos the same as @ProgramFilesDir in autoit ?Yes. But not the same as @ProgramsDir and @ProgramsCommonDir, which are annoyingly similar. I really wish those had been named @ProfileProgramsDir, or something to be more clear, but it's too late to change it now without breaking legacy code.$rc = _RunDos('set programfiles=e:\backups')MsgBox(0, "program files (should be e:\backups):", @ProgramFilesDir)"set programfiles=e:\backups" works in dos "changedirectorys.cmd"ThanksFrom inside AutoIt, you could just use EnvSet(). If you want to set System Environment variables, then you are better off writing to the registry at: HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment 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...
dancer58 Posted August 24, 2007 Author Share Posted August 24, 2007 I tried EnvSet but it didnot change "@ProgramFilesDir" Am I missing something ;$rc = _RunDos('set programfiles=e:\backups') EnvSet("Programfiles", "e:\backups") MsgBox(0, "program files (should be e:\backups):", @ProgramFilesDir) Link to comment Share on other sites More sharing options...
Tiger Posted August 24, 2007 Share Posted August 24, 2007 this works: RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion", "ProgramFilesDir", "Reg_SZ", "D:\Programme") MsgBox(0, "", @ProgramFilesDir) My UDFs:- _RegEnumKey Link to comment Share on other sites More sharing options...
dancer58 Posted August 24, 2007 Author Share Posted August 24, 2007 Thanks It works fine but the way I will use it I do not want to write directly to the registry I am using it on PEBuilder. The CD will be used on different machines with diferent operating systems Link to comment Share on other sites More sharing options...
PsaltyDS Posted August 24, 2007 Share Posted August 24, 2007 I tried EnvSet but it didnot change "@ProgramFilesDir" Am I missing something ;$rc = _RunDos('set programfiles=e:\backups') EnvSet("Programfiles", "e:\backups") MsgBox(0, "program files (should be e:\backups):", @ProgramFilesDir) You have gotten into the maze of twisty little passages that is "Shell Environments" and how they inherit environment variables. When you run EnvSet() you have only changed the value for any NEW shells that you spawn from that script. Reading the @ProgramFilesDir macro does not go out to the shell, but GetEnv() does. Try this: ConsoleWrite("Debug: @ProgramFilesDir = " & @ProgramFilesDir & @LF) ConsoleWrite("Debug: %ProgramFiles% = " & EnvGet("ProgramFiles") & @LF) EnvSet("ProgramFiles", "G:\Bogus Value\") ConsoleWrite("Debug: @ProgramFilesDir = " & @ProgramFilesDir & @LF) ConsoleWrite("Debug: %ProgramFiles% = " & EnvGet("ProgramFiles") & @LF) Run(@ComSpec & " /k SET") 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...
dancer58 Posted August 24, 2007 Author Share Posted August 24, 2007 (edited) I think I am over my head envset appears to work but @ProgramFilesDir must look elsewhere Does anyone know what @ProgramFilesDir looks at or is there another autoit command I can use I need to change several environment setting, run a program, then set them back where they were I can do it with batch file but need to be able get environment from the computor i'm on Edited August 24, 2007 by dancer58 Link to comment Share on other sites More sharing options...
PsaltyDS Posted August 24, 2007 Share Posted August 24, 2007 I think I am over my head envset appears to work but @ProgramFilesDir must look elsewhereDoes anyone know what @ProgramFilesDir looks at or is there another autoit command I can useI need to change several environment setting, run a program, then set them back where they wereI can do it with batch file but need to be able get environment from the computor i'm onThe @ProgramFilesDir macro reflects what %ProgramFiles% was when AutoIt started. If you do EnvUpdate() it will get a new value, but not what you set with EnvSet(). It will get entirely new environment variable values as though AutoIt had exited and be restarted in a new shell. This new value will reflect what is stored in the System Environment Variable keys, not what you changed with EnvSet(). Like I said, twisty maze of passages... 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