Jump to content

trouble adding value via switch


thuun
 Share

Recommended Posts

I'm revising a little autoit script which sets a value in the registry. The value is the cache amount for a virtual file system, the number represents MB of RAM. I cannot seem to add a $Cmdline value which I'd like to use as an input option.

example, this works...

$memory = MemGetStats()
    $fbwfcache = ($memory[1] / 5 / 1024)
        RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\FBWF", "WinPECacheThreshold", "REG_DWORD", $fbwfcache)
Exit

This doesn't...(??)

Dim $p
If $CmdLine[0] = 0 Then Exit
$CmdLine[1] = $p
 $memory = MemGetStats()
  $fbwfcache = Round($memory[1] / $p / 1024)
 RegWrite("HKLM\SYSTEM\ControlSet001\Services\FBWF", "WinPECacheThreshold", "REG_DWORD", $fbwfcache)
Exit

when I put $cmdline in place of $p it produces a incorrect but noticable result.

this is the issue...

--> $fbwfcache = ($memory[1] / $p / 1024)

When a real number is used it works.

Perhaps someone could offer a suggestion, syntax or otherwise, on how to assign this variable with a cmd line switch. :whistle: Thanks!

Edited by thuun
Link to comment
Share on other sites

I'm revising a little autoit script which sets a value in the registry. The value is the cache amount for a virtual file system, the number represents MB of RAM. I cannot seem to add a $Cmdline value which I'd like to use as an input option.

example, this works...

$memory = MemGetStats()
    $fbwfcache = ($memory[1] / 5 / 1024)
        RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\FBWF", "WinPECacheThreshold", "REG_DWORD", $fbwfcache)
Exit

This doesn't...(??)

Dim $p
If $CmdLine[0] = 0 Then Exit
$CmdLine[1] = $p
 $memory = MemGetStats()
  $fbwfcache = Round($memory[1] / $p / 1024)
 RegWrite("HKLM\SYSTEM\ControlSet001\Services\FBWF", "WinPECacheThreshold", "REG_DWORD", $fbwfcache)
Exit

when I put $cmdline in place of $p it produces a incorrect but noticable result.

this is the issue...

--> $fbwfcache = ($memory[1] / $p / 1024)

When a real number is used it works.

Perhaps someone could offer a suggestion, syntax or otherwise, on how to assign this variable with a cmd line switch. :whistle: Thanks!

Just looking at that, $p should be equal to nothing because you didn't set it equal to anything, you did however set $CmdLine[1] equal to $p, which isn't equal to anything. You have to do it the other way around in the equal statement:

Dim $p
If $CmdLine[0] = 0 Then Exit
 $p = Number($CmdLine[1]);you had this backwards
 $memory = MemGetStats()
  $fbwfcache = Round($memory[1] / $p / 1024)
 RegWrite("HKLM\SYSTEM\ControlSet001\Services\FBWF", "WinPECacheThreshold", "REG_DWORD", $fbwfcache)
Exit

Try that. I also added the number function to convert the string to a numerical value.

"So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire

Link to comment
Share on other sites

Yes you are correct! thx!

However, this is where this gets more interesting...

Once corrected and compiled, It outputs much too large a result.

((from before)...when I put $cmdline in place of $p it produces a incorrect but noticable result.)

Given just:

$fbwfcache = ($memory[1] / $Cmdline[1] / 1024)

(adding Number func., no change)

On a 1GB System, if $Cmdline is 10, result should be about 100MB. It is not. Instead it produces 4294762599 (MB.) as a result.

If you persue a logical course, adding decimals to (the switch) reduce result, logic is not what you'll discover. It just goes haywire. \

If $CmdLine[0] = 0 Then Exit
 $memory = MemGetStats()
  $fbwfcache = Round($memory[1] / Number($CmdLine[1]) / 1024)
 RegWrite("HKLM\SYSTEM\ControlSet001\Services\FBWF", "WinPECacheThreshold", "REG_DWORD", $fbwfcache)
Exit

also malfunctions

I can't find an exmpl. to study,

any thoughts are appreciated!

Edited by thuun
Link to comment
Share on other sites

This works fine for me. What is the problem? I personally don't understand what the exact problem is that you are having.

If $CmdLine[0] = 0 Then Exit
$memory = MemGetStats()
$fbwfcache = Round($memory[1] / Number($CmdLine[1]) / 1024)
Msgbox(0,"Result:",$fbwfcache)

Try this script above, tell me how much RAM you have, and tell me what the message box tells you.

Edited by The Kandie Man

"So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire

Link to comment
Share on other sites

I believe using a dash in front of the number in the cmdline switch was causing the problem.

Prompting the output made this clear, good idea. Hopefully that's that. Thx. Kandy Man!

Edited by thuun
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...