Jump to content

possible to have a variable persist after script finishes?


Mr5o1
 Share

Recommended Posts

Hi all,

like a good little scripter I'm trying to avoid saving logins etc in an ini file or what have you.

however, the script I'm working on requires 2 seperate logins plus other semi-sensitive info (IPs, etc) so its impractical to type this info in every time.

My intention is to use the _StringEncrypt function to encrypt these settings before writing to the settings file. This way, you only have to punch in one password when the script runs, which it uses to decrypt your settings from the ini file.

Problem is, it seems like a waste of resources (however few) to have this script running in the background constantly. but also, it seems impractical to have to put your password in every time you run the script.

So, my question is thus:

is it possible to have save this "password" in ram or someplace in the registry? where it will persist from one instance of the script to the next but be automatically removed on shutdown?

Thanks in Advance!

Link to comment
Share on other sites

I've looked into this a little..

seems like a volatile registry key might fit the bill?

Hopefully I can use regwrite() to do that?

if so.. where abouts do I write the key in the registry so that:

-windows wont ask for permission during script execution

-it will be deleted / lost when the system shuts down

-behaviour will be consistant across xp / vista / 7

any ideas ?

Link to comment
Share on other sites

You can write settings to a file or to the registry.

Use IniWrite and IniRead to write it in a file in with the script directory. Or make a custom implementation with FileRead and FileWrite.

For the registry you can make a key in HKLM\Software\<yoursoftware>\<keyname> and use RegRead and RegWrite.

sorry.. I dont think you read my post.

Im talking about storing a password from one instance to the next, so if you run the script multiple times - you only have to punch in your password once. The password will be used to decrypt the sensitive info which -is- written to an ini file.

using Iniwrite to write the password to an ini file or dumping it in HKLM\Software\ doesnt seem very secure - nor will it be automatically cleared after shutdown.

Link to comment
Share on other sites

One of the basic principles of security is that if you increase security, you're going to decrease usability. You seem to be trying to cheat your way out of that, so I was hoping you'd go with a simple solution. Just going with what you know and write a as secure and usable solution as possible doing that.

In any case, searching helps and it turns this up: http://www.autoitscript.com/forum/index.php?showtopic=96124

Good luck.

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...