Sign in to follow this  
Followers 0
EdDyreen

reset environment variables

17 posts in this topic

#1 ·  Posted (edited)

'

My compiled autoIT program can run a certain program just fine.

if I start my compiled autoIT program from the console or a simple program,

it still runs this program just fine.

But when I spawn my compiled autoIT program from a program that uses a lot ( 19.056 kB ) of conventional memory, the program launched by autoIT exits with an error.

If I reduce the memory the problem goes away.

Now I want to reset all environment variables from within autoIT.

I tried

EnvUpdate()
but it didn't work ? Edited by EdDyreen

• Any number images • Images of any size • Any number of URLs • Any number of lines

Share this post


Link to post
Share on other sites



What do you mean when you say "Now I want to reset all environment variables from within autoIT."? Because I'm not getting what it is you're trying to do.

Also, if you're running out of memory when running the batch file, maybe whatever the batch file is doing should be looked at rather than changing environment variables, they don't take much memory at all.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

I want autoIT not to be aware off or unload these variables propagated by the batch.

I want the environment to become the original environment that was passed to cmd.EXE and not the active environment.

I did a test to see whether autoIT cleared one of the variables, unfortunately it failed as the second msgBox

showed a variable set by the batch and EnvUpdate() did not unset it.

MsgBox_( EnvGet( 'processStart_' ) )
EnvUpdate()
MsgBox_( EnvGet( 'processStart_' ) )
Exit

No, I am not running out of memory when running the batch file, the theoretical max for DOS is 655360 bytes.

Edited by EdDyreen

• Any number images • Images of any size • Any number of URLs • Any number of lines

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

I'll try something different then, I will unset all loaded variables manually,

but I can't find a command in autoIT that provides me an array of all set variables ?

I see no other option than to spawn a hidden cmd window to provide me a list

@for /f "tokens=1 delims==" %%? in ( 'set 2^>nul' ) do >envList.TXT (echo.%%?)

I can then use EnvSet() on the list to free the memory

I will probably need to backup the comspec variable...

I then spawn a new instance of cmd to restore the original environment

@for /f "delims=" %%? in ( 'set 2^>nul' ) do >envSet.TXT (echo.%%?)

I can then use EnvSet() on the list to restore the original environment

I wish someone knew a better way of doing it, ah well...

Edited by EdDyreen

• Any number images • Images of any size • Any number of URLs • Any number of lines

Share this post


Link to post
Share on other sites

You haven't mentioned what error you're getting from the first post, so I can't really tell you what to do. Other than to try and see if you could eliminate the batch file all together and do it in AutoIt instead, which you probably can.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

Mistake 1: You're using a batch file

Mistake 2: Trying to alter your AutoIt executable instead of your batch file

Mistake 3: You're using a batch file

You have AutoIt now... use AutoIt...

If you want some help moving code over from batch to strictly AutoIt we can help.


Spoiler

“Hello, ladies, look at your man, now back to me, now back at your man, now back to me. Sadly, he isn’t me, but if he stopped using ladies scented body wash and switched to Old Spice, he could smell like he’s me. Look down, back up, where are you? You’re on a boat with the man your man could smell like. What’s in your hand, back at me. I have it, it’s an oyster with two tickets to that thing you love. Look again, the tickets are now diamonds. Anything is possible when your man smells like Old Spice and not a lady. I’m on a horse.”

 

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

I am not trying to solve an error, nor am I trying to eliminate a batch file, I am trying to unset all variables propagated by the host program that spawned this instance ( except for the default onces like path and comspec )

I'll try something different then, I will unset all loaded variables manually,

but I can't find a command in autoIT that provides me an array of all set variables ?

Edited by EdDyreen

• Any number images • Images of any size • Any number of URLs • Any number of lines

Share this post


Link to post
Share on other sites

I am not trying to solve an error, nor am I trying to eliminate a batch file, I am trying to unset all variables propagated by the host program that spawned this instance ( except for the default onces like path and comspec )

You may not be trying to eliminate a batch file, but if it's not working with the batch file you have, then you should be trying to eliminate it because it's broken. Just a thought, but that's something to consider, but carry on with your quest. As to the error part, I thought you said it gave you an error when you ran it with the batch file, so I thought it might be important to the solution, guess that's not important.

I'll try something different then, I will unset all loaded variables manually,

but I can't find a command in autoIT that provides me an array of all set variables ?

There isn't one, there usually isn't a need to know what all the environment variable names are because they are usually only read/set, and you usually know what it is you're wanting to read/set.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

You may not be trying to eliminate a batch file, but if it's not working with the batch file you have, then you should be trying to eliminate it because it's broken.

The batch file isn't broken, it does exactly what I want it to do, filling the memory with variables and then spawn some progams. The funny thing is, autoIT programs seem to run normally, but some other programs I did not design nor do I know which language they were written in seem to crash if conventional memory gets low.

I want my autoIT scripts to restore the default environment.

There isn't one, there usually isn't a need to know what all the environment variable names are because they are usually only read/set, and you usually know what it is you're wanting to read/set.

Is there some kind of winAPI or COM that I can use then, to forfill my need to know what all the environment variable names are ? I don't like having to resort to batch, because it is slow and inneficient. Edited by EdDyreen

• Any number images • Images of any size • Any number of URLs • Any number of lines

Share this post


Link to post
Share on other sites

Here's a script from the AutoIt scriptomatic tool that will read all environment variables using WMI calls, you can take a look at it's output and decide what information you need from it.

; Generated by AutoIt Scriptomatic June 05, 2012

$wbemFlagReturnImmediately = 0x10
$wbemFlagForwardOnly = 0x20
$colItems = ""
$strComputer = "localhost"
FileDelete(@TempDir & "Win32_Environment.TXT")
$Output=""
$Output &= "Computer: " & $strComputer  & @CRLF
$objWMIService = ObjGet("winmgmts:" & $strComputer & "ROOTCIMV2")
$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_Environment", "WQL", _
                                          $wbemFlagReturnImmediately + $wbemFlagForwardOnly)

If IsObj($colItems) then
   For $objItem In $colItems
      $Output &= "#####################################" & @CRLF
      $Output &= "Caption: " & $objItem.Caption & @CRLF
      $Output &= "Description: " & $objItem.Description & @CRLF
      $Output &= "InstallDate: " & WMIDateStringToDate($objItem.InstallDate) & @CRLF
      $Output &= "Name: " & $objItem.Name & @CRLF
      $Output &= "Status: " & $objItem.Status & @CRLF
      $Output &= "SystemVariable: " & $objItem.SystemVariable & @CRLF
      $Output &= "UserName: " & $objItem.UserName & @CRLF
      $Output &= "VariableValue: " & $objItem.VariableValue & @CRLF
      $Output &= "#####################################" & @CRLF
   Next
   ConsoleWrite($Output & @CRLF)
   FileWrite(@TempDir & "Win32_Environment.TXT", $Output & @CRLF )
   Run(@Comspec & " /c start " & @TempDir & "Win32_Environment.TXT" )
Else
   Msgbox(0,"WMI Output","No WMI Objects Found for class: " & "Win32_Environment" )
Endif


Func WMIDateStringToDate($dtmDate)

    Return (StringMid($dtmDate, 5, 2) & "/" & _
    StringMid($dtmDate, 7, 2) & "/" & StringLeft($dtmDate, 4) _
    & " " & StringMid($dtmDate, 9, 2) & ":" & StringMid($dtmDate, 11, 2) & ":" & StringMid($dtmDate,13, 2))
EndFunc

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

Mistake 1: You're using a batch file

Mistake 2: Trying to alter your AutoIt executable instead of your batch file

Mistake 3: You're using a batch file

You have AutoIt now... use AutoIt...

If you want some help moving code over from batch to strictly AutoIt we can help.

Console based applications have been around since computers were invented and will continiue to be around long after we die. Will I also need to use autoIT for writing my website ? Which is currently a combo of php, html, css and javascript ? I only use autoIT because it is has good GUI support, and if I want to write a serious cross-platform program, I use java not autoIT. What are you banging on about ?

Besides, it's not even a batch, maybe it's a vbscript or a C# program, I dunno, because it doesn't matter what the host program is written in. The only thing that matters is whether autoIT can make sure 3th party programs I did not design have enough free conventional memory to run properly.

@BrewManNH

Good idea, some variables like 'userdomain', 'userprofile', 'username' appear to be missing though.

I can always do a regRead of the 'HKLM..CurrentVersionSeCEdit' 'EnvironmentVariables' though.

Thanks for the suggestions made ;)

Edited by EdDyreen

• Any number images • Images of any size • Any number of URLs • Any number of lines

Share this post


Link to post
Share on other sites

If you know the names of some of the variables, you can use EnvGet("username"), for an example, to get the %username% environment variable's value, or use EnvSet("username", "") to clear it.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

Maybe I'm just having a complete brain fart here, but couldn't you just read that from the "set" command?

Threw together fairly quickly, but you could record what the current values are.

#include <Array.au3>
#include <Constants.au3>

Local $foo = Run(@ComSpec & " /c Set",@SystemDir,@SW_HIDE,$STDERR_CHILD + $STDOUT_CHILD)
Local $line, $vRead = ""
While 1
    $line = StdoutRead($foo)
    If @error Then ExitLoop
    If Not $line = "" Then $vRead &= $line & @CRLF
WEnd
If Not $vRead = "" Then
    Local $vSplit = StringSplit($vRead,@CRLF,1)
    Local $Data[1][2]
    $Data[0][0] = 0
    $x = 1
    For $i = 1 To $vSplit[0]
        If StringInStr($vSplit[$i],'=',0) Then
            Local $valSplit = StringSplit($vSplit[$i],'=',1)
            ReDim $Data[UBound($Data) + 1][2]
            $Data[0][0] = $Data[0][0] + 1
            $Data[$x][0] = $valSplit[1]
            $Data[$x][1] = $valSplit[2]
            $x += 1
        EndIf
    Next
    _ArrayDisplay($Data,'ALL VALUES')
EndIf

I may be missing what you're looking for, very long day...


If you try to fail and succeed which have you done?AutoIt Forum Search

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

I don't think I understand the problem fully. I mean, how many hundends/thousands of variables does the batch file set, that it disrupts the execution of the autoit script ? ;)

Here is an idea : Maybe you can run the script before the batch, and then use ShellExecuteWait to execute the batch, than after it's done, main script execution will resume.

Edited by Inverted

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

I don't think I understand the problem fully. I mean, how many hundends/thousands of variables does the batch file set, that it disrupts the execution of the autoit script ? ;)

Here is an idea : Maybe you can run the script before the batch, and then use ShellExecuteWait to execute the batch, than after it's done, main script execution will resume.

You could at least have read this thread to understand what all the fuss is about, before posting,

I am a little tired of people responding to threads without reading carefully, thus spoiling it and blurring usefull posts.

Some have their bleep in their bleep, and I need to be carefull what I say, cause negative opinions are censored here.

This is what I have now,

After running the EnvUpdate_() function the host process'es variables are no longer propageted through applications,

and the default environment variables are restored to the ones you would get after logging off and then on again.

I did not use WMI after all because many variables were missing,

I found it easier to just enumerate the registry,

unfortunately I had to add some values manually.

I did not include all functions the code refers to, you get the idea

; ----------------------------------------------------------------------------------------------------------------------------------
Func EnvUpdate_()
; ----------------------------------------------------------------------------------------------------------------------------------
;    last updated      : 06/06/2012
;
; EnvUpdate() bugfix replacement
;
; Similar effect as logging off and then on again.
; For example, changes to the %path% environment might not take effect until you call EnvUpdate (or you logoff/reboot).
;
;
;debugOn_( $func )
debug_( @CRLF &'inside: ' &$func )
; (
   debug_( 'valid ' &$func &'( ' &$args &' )' )
   ; (
        Local $array1[1], $array2[1], $regPath, $colRegKey, $regKey, $count, $i, $dim
        Local $cmdFullPathFile, $ouFullPathFile
        Local $err = 0
   ; )

   debug_( 'perform ' &$func &'( ' &$args &' )' )
   ; (
        ; Get environment from registry in $array2
        ; (
            ReDim $array1[3]
            $array1[0]   = 'HKLMSYSTEMControlSet001ControlSession ManagerEnvironment'
            $array1[1]   = 'HKCUVolatile Environment'
            $array1[2]   = 'HKCUEnvironment'
            $count       = 0
            For $regPath In $array1
                ;
                $colRegKey = call9_( 'regKeyEnum_', $regPath )
                For $regKey In $colRegKey
                    ;
                    ReDim $array2[ $count + 1 ][2]
                    $array2[$count][0] = $regKey
                    $array2[$count][1] = RegRead( $regPath, $regKey )
                    $count += 1
                    ;
                Next
                ;
            Next
        ; )

        ; Remove duplicates, conflicts &manually add values to $array2
        ; (
            ReDim $array1[13]
            $array1[0]   = 'TEMP'
            $array1[1]   = 'TMP'
            $array1[2]   = 'USERDOMAIN'
            $array1[3]   = 'USERNAME'
            $array1[4]   = 'USERPROFILE'
            $array1[5]   = 'LOGONSERVER'
            $array1[6]   = 'ALLUSERSPROFILE'
            $array1[7]   = 'CommonProgramFiles'
            $array1[8]   = 'COMPUTERNAME'
            $array1[9]   = 'ComSpec'
            $array1[10] = 'ProgramFiles'
            $array1[11] = 'SystemDrive'
            $array1[12] = 'SystemRoot'
            $array2      = arrayDelete_( $array2, 'HOMESHARE' )
            For $i = 0 To UBound( $array1 ) - 1
                ;
                $array2  = arrayDelete_( $array2, $array1[$i] )
                $dim         = UBound( $array2 ) + 1
                ReDim $array2[$dim][2]
                $array2[ $dim - 1 ][0] = $array1[$i]
                $array2[ $dim - 1 ][1] = '%%' &$array1[$i] &'%%'
                ;
            Next
        ; )

        ; persistent $array2 ( ExpandEnvStrings )
        ; (
            For $i = 0 To UBound( $array2 ) - 1
                ;
                $array2[$i][1] = $array2[$i][1]
                ;
            Next
        ; )
        ;_ArrayDisplay( $array2 )

        ; Get active environment in $array1
        ; (
            $cmdFullPathFile     = _TempFile( @TempDir, 'cmd', '.CMD' )
            $ouFullPathFile  = _TempFile( @TempDir, 'ou',    '.CMD' )
            fileWrite_( $cmdFullPathFile,                                                                                                                                        _
                '@echo off &setlocal enableDelayedExpansion'                                                                                                    &@CRLF &     _
                ''                                                                                                                                                          &@CRLF &     _
                '( for /f "tokens=1 delims=^^=&|+/() " %%%%%%%%? in ( ' &"'set 2^>nul'" &' ) do (echo.%%%%%%%%~?) )> "' &$ouFullPathFile &'"'   &@CRLF &     _
                ''                                                                                                                                                          &@CRLF &     _
                'endlocal &exit 0'                                                                                                                                               _
            )
            RunWait( @COMSPEC & ' /k "' &$cmdFullPathFile &'"', @TempDir, @SW_HIDE )
            call9_( 'fileDelete_', $cmdFullPathFile, 1 )
            $array1 = call9_( 'fileRead_', $ouFullPathFile, 1 )
            call9_( 'fileDelete_', $ouFullPathFile, 1 )
        ; )
        _ArrayDisplay( $array1 )

        ; Clean the active environment ( remove all propagated values )
        ;MsgBox_( 'TMP=%TMP%' )
        ; (
            For $i In $array1
                ;
                EnvSet( $i )
                ;
            Next
        ; )

        ; Restore the default environment
        ;MsgBox_( 'TMP=%TMP%' )
        ; (
            For $i = 0 To UBound( $array2 ) - 1
                ;
                EnvSet( $array2[$i][0], $array2[$i][1] )
                ;
            Next
        ; )
        ;MsgBox_( 'TMP=%TMP%' )
    ; )
;
debug_( 'outside: ' &$func )
SetError( $err )
EndFunc
; )
; ----------------------------------------------------------------------------------------------------------------------------------
#cs
MsgBox( 0, '', 'begintest' )
MsgBox( 0, '', 'endoftest' )
Exit
#ce
; )
; ----------------------------------------------------------------------------------------------------------------------------------
Func fileRead_( $fullPathFile = '', $sErr = False )
; ----------------------------------------------------------------------------------------------------------------------------------
;    last updated      : 05/06/2012
;
;debugOn_( $func )
debug_( @CRLF &'inside: ' &$func )
; (
   debug_( 'valid ' &$func &'( ' &$args &' )' )
   ; (
        Local $handle, $array[1], $line, $count
        Local $err = 0
   ; )

   debug_( 'perform ' &$func &'( ' &$args &' )' )
   ; (
        If call9_( 'fileExist_', $fullPathFile, $sErr ) Then
            ;
            $handle  = FileOpen( $fullPathFile )
            $count   = 0
            $line    = True
            While $line
                ;
                $line = FileReadLine( $handle )
                If $line <> '' Then
                    ;
                    ReDim $array[ $count + 1 ]
                    $array[$count] = $line
                    $count += 1
                    ;
                EndIf
                ;
            WEnd
            FileClose( $handle )
            ;
        Else
            ;
            $err = @error
            ;
        EndIf
    ; )
;
debug_( 'outside: ' &$func )
SetError( $err )
Return $array
EndFunc
; )
; ----------------------------------------------------------------------------------------------------------------------------------
#cs
MsgBox( 0, '', 'begintest' )
MsgBox( 0, '', 'endoftest' )
Exit
#ce
; )
; ----------------------------------------------------------------------------------------------------------------------------------
Func arrayDelete_( $array, $value )
; ----------------------------------------------------------------------------------------------------------------------------------
;    last updated      : 06/06/2012
;
;debugOn_( $func )
debug_( @CRLF &'inside: ' &$func )
; (
   debug_( 'valid ' &$func &'( ' &$args &' )' )
   ; (
        Local $i
        Local $err = 0
   ; )

   debug_( 'perform ' &$func &'( ' &$args &' )' )
   ; (
        If IsArray( $array ) Then
            ;
            Do
                ;
                $err = 0
                For $i = 0 To UBound( $array ) - 1
                    ;
                    If $array[$i][0] = $value Then
                        ;
                        _ArrayDelete( $array, $i )
                        $err = 1
                        ExitLoop
                        ;
                    EndIf
                    ;
                Next
                ;
            Until Not $err
            ;
        Else
            ;
            call9_( 'panic_', 21 ); $error[21] = 'object type invalid'
            ;
        EndIf
    ; )
;
debug_( 'outside: ' &$func )
SetError( $err )
Return $array
EndFunc
; )
; ----------------------------------------------------------------------------------------------------------------------------------
#cs
MsgBox( 0, '', 'begintest' )
MsgBox( 0, '', 'endoftest' )
Exit
#ce
; )

And it works, conventional memory is freed and programs depending on it can run fast and safely.

Someone from Microsoft once told me,

what we hate even more than helping people, is to help people that are trying to help people :)

Edited by EdDyreen

• Any number images • Images of any size • Any number of URLs • Any number of lines

Share this post


Link to post
Share on other sites

I thought of that someone wrote way back when. It doesn't technically reduce the memory being used by a process, but it does free up the amount of memory it's using by paging what it is using to the page file. It might be of some use if you notice that just one of your programs is taking up all the conventional memory.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

#17 ·  Posted (edited)

@Country73

Your code to get the environment using the set command is prone to failure as it does not take into account variables may contain linefeeds. But my code was wrong too. I debugged it though, here is an example that proves $LF can be part of a variable and corrupt the code.

@echo off &setlocal enableDelayedExpansion

set var=^

)hello^<^>"<>"there

echo.this is obviously wrong
echo.
set
echo.

echo.this is better
echo.
for /f "tokens=1 delims==" %%? in ( 'set' ) do (

    set "?=%%~?" &if "%%~?" == "!?: =!" (

        2>nul >nul set "%%~?" &&(echo.%%~?)
    )
)

pause
exit

@BrewManNH

Very interesting link indeed ;)

Edited by EdDyreen

• Any number images • Images of any size • Any number of URLs • Any number of lines

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