Ad Widget

Collapse

Error - System cannot find the specified path

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gustavoParis
    Junior Member
    • Jan 2023
    • 9

    #1

    Error - System cannot find the specified path

    Hi, i tried to use a item key to call a .batch file to delete and copy a file to one location to another, but i getting this error in the batch execution

    Click image for larger version

Name:	image.png
Views:	912
Size:	6.3 KB
ID:	465893

    the code are this:

    echo off
    del C:\Users\%USERNAME%\.nuke\preferences13.2.nk
    copy /y "C:\Logs\preferences13.2.nk" "C:\Users\%USERNAME%\.nuke\preferences13.2.nk" >nul
    hostname

    I build ​the key like this (using 1m update interval to run some tests):
    Click image for larger version

Name:	image.png
Views:	867
Size:	36.1 KB
ID:	465894

    The batch file runs fine if executed manually in windows, but for some reason Zabbix cannot find the path

    Has someone have this issue or can help solve it ?

    Thanks in advance.
    ​
    ​
  • Piotrekzielony
    Junior Member
    • Oct 2021
    • 17

    #2
    %USERNAME% is the problem. It might not exists in context of zabbix agent.

    Comment

    • gustavoParis
      Junior Member
      • Jan 2023
      • 9

      #3
      Oh, thanks for the advice
      Is there a way to get around this problem ?
      I'm trying using a Call batch, it work, but the problem persists with this one
      Current trying to copy one "default" file to users folder in windows in a way i dont need to manually write all machines account folder in all batch files.

      Comment

      • Piotrekzielony
        Junior Member
        • Oct 2021
        • 17

        #4
        Not sure if zabbix is good solution for what you are trying to accomplish.

        zabbix agent is not aware of user profiles since it does run as its own profile only. To the rest of user accounts it probably doesnt even have access. It will work for you if you hardcode your profile (or run by you) but zabbix wont be able to deploy it for all other users.

        Depends on your infrastructure, there are other tools that can do it. Group policies? PS scripts on logon, ansible?
        Last edited by Piotrekzielony; 13-06-2023, 21:49.

        Comment

        • gustavoParis
          Junior Member
          • Jan 2023
          • 9

          #5
          I suspect permissions would be an issue
          But even using a shell script to call another one to use the original script i still get error messages about the patch. Already gave admin permissions to ever user to write the Users folder, but still getting path errors.
          About other tools maybe is valid to take a look, but the ideal would be using zabbix for this

          Comment

          • gustavoParis
            Junior Member
            • Jan 2023
            • 9

            #6
            Do you know how to call and .ps1 file using another in zabbix ?
            Maybe this work out.

            Comment

            • Piotrekzielony
              Junior Member
              • Oct 2021
              • 17

              #7
              Originally posted by gustavoParis
              I suspect permissions would be an issue But even using a shell script to call another one to use the original script i still get error messages about the patch. Already gave admin permissions to ever user to write the Users folder, but still getting path errors.
              About other tools maybe is valid to take a look, but the ideal would be using zabbix for this
              You cant use %USERNAME% at all when calling from zabbix agent process. Usernam for zabbix agent is only for user under which zabbix service is running. Even when you call other script it wont make any difference. %USERNAME%is only a variable for a single session, not for all users folders.


              But I still dont understand reason to have it as "item" really that will fire every so often or regulal basis ( single file copy to profile)? It has to be triggered by something like during login or something else? you would have to use triggers and trigger actions (if you really have to use zabbix for it).

              figure out what triggers it and how to capture who is doing it (for profile name) only then you setup triggers that will take username (as macro) and use trigger to action the function using either script or user parameter (script that can take args) or other more direct form like ssh/winrm

              This is too much just to remove single file and then copy another. Windows scheduler is probably way to go with this if you can't use group policies or other tools.

              zabbix it's not the best for that kind of operation and imo it's overkill
              Last edited by Piotrekzielony; 13-06-2023, 22:22.

              Comment

              • gustavoParis
                Junior Member
                • Jan 2023
                • 9

                #8
                Originally posted by Piotrekzielony
                Not sure if zabbix is good solution for what you are trying to accomplish.

                zabbix agent is not aware of user profiles since it does run as its own profile only. To the rest of user accounts it probably doesnt even have access. It will work for you if you hardcode your profile (or run by you) but zabbix wont be able to deploy it for all other users.

                Depends on your infrastructure, there are other tools that can do it. Group policies? PS scripts on logon, ansible?
                About our infrastructure to clarify any question

                We don't have and AD server, since this is an big issue, anything we change has to be done manually in about 40 workstations.
                For this reason ever automation are done via zabbix since is easy to control and implement in our structure.
                This copy has to be done in the of start working hours and after we close the day, thus the need for some automation.
                We already have some batch files running in zabbix, is just this one who refuses to work.

                Comment

                • Piotrekzielony
                  Junior Member
                  • Oct 2021
                  • 17

                  #9
                  Becouse of this variable.

                  Alternatively you can build more complex powershell script (or other script type you fancy) that will enumerate users and hook zabbix that will trigger it if you really need to use it.

                  you need to change zabbix agent service to run as local administrator that can have access to those folders.

                  In PS just check usernames , add to list. for each username "do removal and copying" loop.

                  Note: zabbix might fail if you also want result - there is max 30 seconds timeout from any script (default 3 sec)
                  but you can have item trapper and if you finish with script you can add another line that will push info to zabbix via zabbix_sender with results.

                  https://www.zabbix.com/documentation...mtypes/trapper

                  You can try this as starting point but not sure if its working (oh chatgpt):
                  HTML Code:
                  $sourceFilePath = "C:\Logs\preferences13.2.nk"
                  
                  $users = Get-WmiObject -Class Win32_UserProfile | Where-Object { $_.Special -ne $true } | Select-Object -ExpandProperty LocalPath
                  
                  foreach ($userPath in $users) {
                  $userName = Split-Path $userPath -Leaf
                  $destinationFolderPath = Join-Path $userPath ".nuke"
                  $destinationFilePath = Join-Path $destinationFolderPath "preferences13.2.nk"
                  
                  # Create the destination folder if it doesn't exist
                  if (-not (Test-Path -Path $destinationFolderPath)) {
                  New-Item -ItemType Directory -Path $destinationFolderPath | Out-Null
                  }
                  
                  # Copy the file and overwrite if it already exists
                  Copy-Item -Path $sourceFilePath -Destination $destinationFilePath -Force
                  
                  Write-Host "File copied to user: $userName"
                  }
                  ​
                  Last edited by Piotrekzielony; 13-06-2023, 23:22.

                  Comment

                  Working...