MrChris Posted July 10, 2006 Share Posted July 10, 2006 (edited) If I have an application that when opened it reads what the env var is, in this case %ALLUSERSPROFILE% and creates a folder in it, How can I redirect that application into thinking that %ALLUSERSPROFILE% is in a diff location but only for the duration that the script is run? I dont see a macro for @ALLUSERSPROFILE. for example. application.exe reads env var %ALLUSERSPROFILE%\Application Data\ to see if a folder exists or not if it does not it creates it. I want the application to think that the %ALLUSERSPROFILE% has another value. I dont see a Macro for it not do I know how to update that value at a global system wide level but only for the duration of the script. I was only able to come up with this before the application.exe is run but how to I get it back to its prier value after runwait ("application.exe") is closed? $allusersprofile = EnvGet("ALLUSERSPROFILE" ) EnvSet ( $allusersprofile , @ScriptDir & '\AllUserData' ) EnvUpdate() Hope that makes sense. MrChris Edited July 10, 2006 by MrChris Link to comment Share on other sites More sharing options...
cppman Posted July 10, 2006 Share Posted July 10, 2006 (edited) $allusersprofile = EnvGet("ALLUSERSPROFILE" ) EnvSet ("ALLUSERSPROFILE" , @ScriptDir & '\AllUserData' ) EnvUpdate() ;on close EnvSet("ALLUSERSPROFILE", $allusersprofile) ?? i think.. im sure u can use $allusersprofile because it is never changed... btw, EnvSet($allusersprofile, @ScriptDir & '\AllUserData') should be EnvSet("ALLUSERSPROFILE", @ScriptDir & '\AllUserData') beacuse $allusersprofile contains the string to the all users folder.. thats not the name of the Environment Variable. Edited July 10, 2006 by CHRIS95219 Miva OS Project Link to comment Share on other sites More sharing options...
MrChris Posted July 10, 2006 Author Share Posted July 10, 2006 Will that application I use in a RunWait command be able read the new var? Or does the var only apply to other commands inside the script? MrChris Link to comment Share on other sites More sharing options...
cppman Posted July 10, 2006 Share Posted July 10, 2006 (edited) $allusersprofile is only accessible from within this script. if u need other programs to have access to it try writing a registry key. RegWrite("HKEY_LOCAL_MACHINE\Software", "test", "REG_SZ", $allusersprofile) ;write a registry value containing the $allusersprofile contents.. $value = RegRead("HKEY_LOCAL_MACHINE\Software", "test");read the value. $value now equals whatever $alluserprofiles equaled when u wrote the registry key.. im not sure if that is what u asked... lol Edited July 10, 2006 by CHRIS95219 Miva OS Project Link to comment Share on other sites More sharing options...
MrChris Posted July 10, 2006 Author Share Posted July 10, 2006 Well yes and no. When application.exe opens it creates a subfolder in %ALLUSERPROFILE%\Application Data\testfolder. Since I am not sure where in the reg the %alluserprofile% is stored (I have searched high and low in the reg) I am unable to redirect %alluserprofile% to have a new value. Link to comment Share on other sites More sharing options...
cppman Posted July 10, 2006 Share Posted July 10, 2006 (edited) im confused... What exactly are you trying to do? Is application.exe a program you wrote or someone else's? AH! I see... nvm, the first script i did should do the trick.. $allusersprofile = EnvGet("ALLUSERSPROFILE" ) EnvSet ("ALLUSERSPROFILE" , @ScriptDir & '\AllUserData' ) EnvUpdate() ;on close WinWaitClose("AppTitle", "AppText") EnvSet("ALLUSERSPROFILE", $allusersprofile) Environment Variables are accessible from any program that can read them. When you set an environment variable, any program can read that new value. So that code should work. Edited July 10, 2006 by CHRIS95219 Miva OS Project Link to comment Share on other sites More sharing options...
MrChris Posted July 10, 2006 Author Share Posted July 10, 2006 I did not create the app nor is it a AutoIt compiled app. If I use the code you stated above it does not seem to be changing the actual system var. If I use the below code to change the var and then open up a command prompt and type in SET to view my vars it still says that %ALLUSERPROFILE% still has a value of C:\Documents and Settings\All Users. $allusersprofile = EnvGet("ALLUSERSPROFILE" ) EnvSet ("ALLUSERSPROFILE" , @ScriptDir & '\AllUserData' ) EnvUpdate() Link to comment Share on other sites More sharing options...
cppman Posted July 10, 2006 Share Posted July 10, 2006 (edited) ah. A environment variable set in this way will only be accessible to programs that AutoIt spawns (Run, RunWait). Once AutoIt closes, the variables will cease to exist. well that sux. lol, im not sure what else you can do..sry Edited July 10, 2006 by CHRIS95219 Miva OS Project 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