Bertman Posted February 26, 2006 Share Posted February 26, 2006 With this script you can read all the Windows Variable. I was looking for this for a long time, but it is so damn easy. Maybe you like it !; Path $var = "%TEMP%\Bert Nieuwenampsen"; Run a dos prompt and put output in text-file in the Temp directory RunWait (@ComSpec & " /c echo " & $var & " >" & @TempDir & "\var.txt"); Read text-file $var = FileReadLine ( @TempDir & "\var.txt" ); Show messagebox with the complete path MsgBox ("", "Variable", $var); Delete text-file FileDelete ( @TempDir & "\var.txt" )Read_WinVariable.au3 Link to comment Share on other sites More sharing options...
GaryFrost Posted February 26, 2006 Share Posted February 26, 2006 (edited) With this script you can read all the Windows Variable. I was looking for this for a long time, but it is so damn easy. Maybe you like it ! Far as I can tell that only gets the temp folder path try: expandcollapse popup#include <Constants.au3> #include <Array.au3> Dim $env_vars[1][2], $temp_line = "", $temp_env $foo = Run(@ComSpec & " /c set", "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) While 1 $line = StdoutRead($foo) If @error = -1 Then ExitLoop $temp_line = $temp_line & $line Wend $temp_env = StringSplit($temp_line, @CRLF, 1) ; clean out any empty lines For $x = $temp_env[0] To 1 Step -1 If $temp_env[$x] = @LF Or $temp_env[$x] = @CR Or Not StringLen($temp_env[$x]) Then _ArrayDelete($temp_env,$x) $temp_env[0] = $temp_env[0] - 1 EndIf Next ReDim $env_vars[$temp_env[0]][2] For $x = 1 To $temp_env[0] $temp_line = StringSplit($temp_env[$x],"=") $env_vars[$x - 1][0] = $temp_line[1] $env_vars[$x - 1][1] = $temp_line[2] Next For $x = 0 To UBound($env_vars) - 1 $lResult = MsgBox(1, $env_vars[$x][0], $env_vars[$x][1]) Switch $lResult Case 1; ok Case 2; cancel ExitLoop EndSwitch Next Edited February 27, 2006 by gafrost SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
FuryCell Posted February 27, 2006 Share Posted February 27, 2006 why not just do:h MsgBox(0,"",EnvGet("temp")) that appears to work fine. HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code. Link to comment Share on other sites More sharing options...
Bertman Posted February 27, 2006 Author Share Posted February 27, 2006 Far as I can tell that only gets the temp folder pathNope, you can get all the Windows Variable !Like:ALLUSERSPROFILEAPPDATACommonProgramFilesCOMPUTERNAMEHOMEDRIVEHOMEPATHProgramFilesSystemDriveSystemRootTEMPTMPUSERPROFILEwindirBut yeah you can use 'EnvGet ( "appdata" )' I didn't know that one Link to comment Share on other sites More sharing options...
GaryFrost Posted February 27, 2006 Share Posted February 27, 2006 Nope, you can get all the Windows Variable !Like:ALLUSERSPROFILEAPPDATACommonProgramFilesCOMPUTERNAMEHOMEDRIVEHOMEPATHProgramFilesSystemDriveSystemRootTEMPTMPUSERPROFILEwindirBut yeah you can use 'EnvGet ( "appdata" )' I didn't know that one Yes I know about EnvGet, but your post was misleading the users into that the script would return all environment variables, therefore I posted a script that would do that with out having to hardcode any particular one in. SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
Xenobiologist Posted February 27, 2006 Share Posted February 27, 2006 (edited) Hi, @gafrost: You forget to #include<Constants.au3> in your script. (I think). Without it throws an error. But nevertheless, always nice scripts you write! So long, Mega Now it works, fine! Edit: After gafrost did. Edited February 27, 2006 by th.meger Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times 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