Announcement

Collapse
No announcement yet.

Need Help!

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Need Help!

    Hello,

    I'm working on a small project that collects user info, WAN/LAN IP, computer name etc.

    On Startup, I created a folder based on the computer name and a txt file based on computer name, that holds all the above info. All the data is stored on a sever.

    My goal is to some how have AMS on startup check computer name and look for the corresponding folder for an INI and read the data from the INI.

    What would be the syntax used to have it check the computer name and then look for the corresponding folder that matches and read the INI data? Do I store the data to the registry then read it back and check? Not sure how to handle this or the syntax that would make this work.

    Thanks in advance!

  • #2
    Here what I got working. I was able to get almost everything working. I'm missing how to save to the correct folder. I know my syntax is wrong. Can someone show me the right syntax?

    Code:
    Asset1 = Input.GetText("AssetTag");
    
    Find = Folder.Find("C:\\CST\\Devices", Asset1, false, nil);
    if result == Find then
    INIFile.SetValue("C:\\CTS\\Devices\\" ..Find.., ..Asset1.. ".ini", "Alert", "1", "Enabled");
    end

    Comment


    • #3
      Originally posted by Widget View Post
      Here what I got working. I was able to get almost everything working. I'm missing how to save to the correct folder. I know my syntax is wrong. Can someone show me the right syntax?

      Code:
      Asset1 = Input.GetText("AssetTag");
      
      Find = Folder.Find("C:\\CST\\Devices", Asset1, false, nil);
      if result == Find then
      INIFile.SetValue("C:\\CTS\\Devices\\" ..Find.., ..Asset1.. ".ini", "Alert", "1", "Enabled");
      end
      Folder.Find: A table containing the paths to all of the folders that were found. If no folders were found or the action fails, nil is returned. You can use Application.GetLastError to determine whether this action failed, and why.
      PHP Code:
      Asset1 Input.GetText("AssetTag");

      Find Folder.Find("C:\\CST\\Devices"Asset1falsenil);
      -- 
      if 
      Find and #Find > 0 then
        
      for index,folder in pairs(Find) do
           
      INIFile.SetValue("C:\\CTS\\Devices\\" ..folder.., ..Asset1.. ".ini""Alert""1""Enabled");
        
      end
      end 

      Comment


      • #4
        oops, replace
        PHP Code:
        INIFile.SetValue("C:\\CTS\\Devices\\" ..folder.., ..Asset1.. ".ini""Alert""1""Enabled"); 
        to
        PHP Code:
        INIFile.SetValue(folder..'\\'..Asset1.. ".ini""Alert""1""Enabled"); 

        Comment


        • #5
          RaMB,

          I tried your code and it did not work. The folder does exist, but the ini is not being created in it. Thanks

          Code:
          Asset1 = Input.GetText("AssetTag");
          
          Find = Folder.Find("C:\\CST\\Devices", Asset1, false, nil);
          -- 
          if Find and #Find > 0 then
            for index,folder in pairs(Find) do
              INIFile.SetValue(folder..'\\'..Asset1.. ".ini", "Alert", "1", "Enabled"); 
              
            end
          end

          Comment


          • #6
            If you just want to check an INI file in folder Asset1:

            [php]Asset1 = Input.GetText("AssetTag");
            if Folder.DoesExist("C:\\CST\\Devices\\"..Asset1) then
            -- File: "C:\\CST\\Devices\\Devicename\\Devicename.ini"
            INIFile.SetValue("C:\\CST\\Devices\\"..Asset1.."\\ "..Asset1..".ini", "Alert", "1", "Enabled");

            -- File: "C:\\CST\\Devices\\Devicename.ini"
            --INIFile.SetValue("C:\\CST\\Devices\\"..Asset1..".i ni", "Alert", "1", "Enabled");
            end[php]

            You just need check the folder exist or not then create file. Do not need find

            Comment


            • #7
              RaMB,

              Thanks that worked. However I'm still having a slight issue. On timer, I want to read the value of the ini that was created on a server. The below code to get ini value does not work. But if I change the code to point local it works fine. Using your code I can set ini values and can copy file to server I just can get the ini value. Id there something wrong with my code? Thanks in advance!


              Code:
              --Working
              LD = INIFile.GetValue("C:\\CTS\\Console\\Devices\\" ..Asset1.. ".ini", "Alert", "1");
              Code:
              if e_ID == 10 then
              Asset1 = Input.GetText("AssetTag");
              
              ------Alert--Get the value data 
              LD = INIFile.GetValue("\\\\myserver.myserver.com\\Console\\Devices\\" ..Asset1.. ".ini", "Alert", "1");
              if (LD == "Enabled") then
              Dialog.Message("Notice", "Your Enabled", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
              Audio.Load(CHANNEL_USER1, "C:\\Windows\\whoop.wav", true, true);
              Audio.Play(CHANNEL_ALL);    
              --execute wallpaper
              DLL.CallFunction(_SystemFolder .. "\\User32.dll", "SystemParametersInfoA", "20,0,\"" .. _WindowsFolder .. "\\Lost_Wallpaper.jpg\",1", DLL_RETURN_TYPE_INTEGER, DLL_CALL_STDCALL);
              
              elseif (LD == "Disabled") then
              Dialog.Message("Notice", "Your Disabled", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
              Audio.Stop(CHANNEL_ALL);
              DLL.CallFunction(_SystemFolder .. "\\User32.dll", "SystemParametersInfoA", "20,0,\"" .. _WindowsFolder .. "\\Nick_Wallpaper.jpg\",1", DLL_RETURN_TYPE_INTEGER, DLL_CALL_STDCALL);
              end
              
              elseif e_ID == 15 then
              ----Copies Log files to server
               Asset1 = Input.GetText("AssetTag");
               if Folder.DoesExist("\\\\myserver.myserver.com\\Console\\Devices\\"..Asset1) then
              File.Copy("C:\\CTS\\" ..Asset1.. "-HTSD.txt", "\\\\\\\\myserver.myserver.com\\Console\\Devices\\Logs\\", true, true, false, true, nil);
               end
              end

              Comment

              Working...
              X