Jump to content

Case Statement Madness!


dmollico
 Share

Recommended Posts

OK, I wrote a fairly complicated logon script with this wonderful tool called AutoIt. Heard of it? :idiot:

What I do, is when someone logs into my network, it takes their user name and uses that to look up their name in some case statements.

When it finds their name, it populates variables based on information i have stored like:

Case $name = "hgillmoore"

          $fullname = "Happy Gillmore"
          $pii = "C5689"
          $scm = "C1234"
          $platform = "N/A"
          $ipadd = "10.62.221.100"
          $phone = "555-555-5555"
          $title = "CEO Of this Corp"
          $bank = "Main Branch"
          $emailadd = "gillmooreh"

    Case Else

        MsgBox(0, "Error", "The input did not match any records in my database")
    Exit
EndSelect

Since employees change all the time, I would like to be able to just keep the case statements in a seperate file, then have the script reference it just for those variables. This is also helpful if I wanted to use other programs to reference the same information. Your ideas guys? :D

Link to comment
Share on other sites

Like a database! Good idea.

I'll create a small script that uses an INI file.

Hold on...

Edit:

Here you go.

An example.

$IniFile = @ScriptDir & "\Info.ini"

$fullname = InputBox("Enter name", "Enter the full name of a person.")
If @error Then Exit

$pii = INIRead($IniFile, $fullname, "pii", "")
If $pii = "" Then
   MsgBox(0, "Error", "The input did not match any records in my database")
   EXIT
Else   
   $scm = INIRead($IniFile, $fullname, "scm", "")
   $platform = INIRead($IniFile, $fullname, "platform", "")
   $ipadd = INIRead($IniFile, $fullname, "ipadd", "")
   $phone = INIRead($IniFile, $fullname, "phone", "")
   $title = INIRead($IniFile, $fullname, "title", "")
   $bank = INIRead($IniFile, $fullname, "bank", "")
   $emailadd = INIRead($IniFile, $fullname, "emailadd", "")
EndIf

;---- End of script


;--- Example INI file
[Happy Gillmore]
pii = C5689
scm = C1234
platform = N/A
ipadd = 10.62.221.100
phone = 555-555-5555
title = CEO Of this Corp
bank = Main Branch
emailadd = gillmooreh
Edited by SlimShady
Link to comment
Share on other sites

Have you considered an actual database? If you do that you can then use an inline SQL command to add, edit, or remove everything you want.

JS

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Link to comment
Share on other sites

The actual database idea is a good one, however, I don't know any of the sql commands to do such a thing. Granted, i know a few commands, but no command line utilities....

If you have any suggestions, i'd love to hear them! The inifile read idea worked VERY nicely. I'm currently using it.

The sql idea appeals to me because I think it would be nice to be able to update the database with a tool, rather than in raw data. Although i'm sure i could modify my current ini file read tool to check for current entries, and populate information if it exists, if not,prompt my for info, then do an inifilewrite

Slim: It's your fault you showed me this tool! Now i'll be doing a lot more with it :idiot:

Link to comment
Share on other sites

Give me a minute I might have to upload the command line program I have used.

JS

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Link to comment
Share on other sites

SQLCmd.exe can be found at the following AnalogX.com

Check it out and let me know what you think. I like the little utility.

JS

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

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