1 2 3 Previous Next 37 Replies Latest reply on Jul 19, 2017 1:03 AM by Schroedi

    Batch file distribution fails

    Schroedi Apprentice

      Hi Community,

       

      i'm trying to distribute a batch file via Landesk. The batch file comes with a seperate registry file.
      With this method i want to activate auto logon on a Windows 7 system.

       

      Batch file:

       

      @echo off
      regedit /s autologon.reg

       

      Registry file:

       

      Windows Registry Editor Version 5.00

      [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon]

      "AutoAdminLogon"="1"
      "DefaultUserName"="Name"
      "DefaultPassword"="Password"

       

      Both files are bind in a distributed package correctly.
      After i start the sheduled task Landesk copies the files in the temp folder on the lokal machine. The task switches to "Successful".
      But the registry keys didn't change. When i run the batch file manually all registry keys will be set immediately.

       

      Do you have any idea about this? Thank you!

        • 1. Re: Batch file distribution fails
          phoffmann SupportEmployee

          What user-context are you running this as?

           

          What do the LANDesk logs say for this task on the client? (if nothing else, they may give you an error code to start looking for).

           

          Have you used something like ProcMon (Sysinternals tool that is freely available) to monitor a run of this?

           

          I would *suspect* that you'd likely see some sort of registry access failure (due to permissions, for instance) -- as user context (and thus - potential lockdown) is a big factor in any kind of software distribution type task.

           

          Basic troubleshooting guides can be foudn here:

          - How to quickly troubleshoot a Software Distribution job

          - How to use Registry Keys in a Batch File

           

          Start with that to gather more data. Other than "it doesn't work right now", you don't have information on the error-code / "reason why it doesn't work" (again - my guess is that Windows flat out doesn't LET you access the registry for some reason in whichever user-context you're running the task as), which are key bits of data here .

          • 2. Re: Batch file distribution fails
            carlos Expert

            I would also start with a simple batch, just to see if it runs then try to run it manually on the test computer, then work my way down from there.

            • 3. Re: Batch file distribution fails
              MarXtar ITSMMVPGroup

              What version are you running?

               

              If 2016 or above why not try using a windows action package to make the registry changes. Tends to overcome some of the barriers associated with batch files especially when trying to reference external files.

               

              I quite like using the reg.exe method since that means everything is done from within the batch without the external file but it can take longer to write.

               

              Mark McGinn

              MarXtar Ltd/MarXtar Corporation

              http://ivantione.marxtar.com

              Ivanti One Development Partner

               

              Try MarXtar State Management for Ivanti to Better Understand and Manage your Assets

              • 4. Re: Batch file distribution fails
                Schroedi Apprentice

                Like I said. Performing the batch file manually works fine.

                We're using version 9.60.2.48. I think it's 2014.

                 

                I also tried to develop the keys via "Update registry" action in my provisioning template. But it doesn't work.

                • 5. Re: Batch file distribution fails
                  Schroedi Apprentice

                  I red and tested a little bit around yesterday. Thanks for the tips by the way.

                  Sadly the problem still exists

                   

                  Landesk installs the package with the local system account. System is allowed to change settings in this specific registry key.

                  I also tried to install the package via administrative domain account.

                   

                  Installation result DB50000

                  The log file says that the process is complete with result 229965824 (0x0db50000 - code 0)

                  • 6. Re: Batch file distribution fails
                    MarXtar ITSMMVPGroup

                    You might have an issue with it finding the registry file.

                     

                    Try using %~dp0 when specifying the .reg file so that you are using the full directory name of the batch file location. The working directory may be different when you launch via ldms.

                     

                     

                    Mark McGinn

                    MarXtar Ltd/MarXtar Corporation

                    http://ivantione.marxtar.com

                    Ivanti One Development Partner

                     

                    Try MarXtar State Management for Ivanti to Better Understand and Manage your Assets

                    • 7. Re: Batch file distribution fails
                      Schroedi Apprentice

                      Tried it with %~dp0 and full path. Same problem.

                      System has full control on folder, files, and registry keys.

                       

                      I believe it's something simple...

                      • 8. Re: Batch file distribution fails
                        ahe Expert

                        Hi,

                         

                        as Mark wrote, I prefer reg.exe too instead of using an additional file and get in path troubles :-)

                         

                        Did you check, if both files are copied to the client, before the batch was started and if they are stored in the same Directory?

                         

                        I would add some lines inside your Batch:

                         

                        @echo off
                        if exist "your path to reg file\autologon.reg" (
                            regedit /s autologon.reg
                        ) else (
                            echo no file exist >> c:\windows\temp\autologon_err.log
                        )
                        

                         

                        If a file autologon_err.log is created, you know, that the file does not exist during runtime of your Batch.

                        If no file exist, something is wrong with your reg file... I think the error log will appear :-)

                         

                        To hide such, add the reg.exe commands in your Batch like this: (not tested, quick&dirty hack)

                         

                        @echo off
                        SET "LOGONKEY="HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon"
                        reg add "%LOGONKEY" /V "AutoAdminLogon" /t REG_DWORD /D 1 /F
                        reg add "%LOGONKEY" /V "DefaultUserName" /t REG_SZ /D "Name" /F
                        reg add "%LOGONKEY" /V "DefaultPassword" /t REG_SZ /D "Password" /F
                        if errorlevel 0 (
                         set "code=0"
                        ) else (
                         set "code=-1"
                        )
                        Exit /b %code%
                        

                         

                        BR

                        Axel

                        • 9. Re: Batch file distribution fails
                          Schroedi Apprentice

                          I created a single batch with your commands. Just note: AutoAdminLogon is a string, but the rest was right so far

                          Anyway. With this method I have exact the same problem.

                           

                          Landesk loads the file into the temp folder on the local machine but doesn't execute it / or execute it without any effect.

                          • 10. Re: Batch file distribution fails
                            MarXtar ITSMMVPGroup

                            OK, confused a little here:

                             

                            If you are sending a batch file, the client should download to the sdmcache directory before launching (or at least a patch under the sdmcache that matches the path it came from on the source).

                             

                            You mention a temp folder on the client, so what directory do you mean by that?

                             

                            Are you sure this isn't launching? What do the log files tell you?

                             

                            The agent running as localsystem should have the privileges to do this, so either the batch isn't being launched, or somehow it doesn't have the rights, or there's something else going on. Can you post the full log file section rather than just the result code?

                             

                            Mark McGinn

                            MarXtar Ltd/MarXtar Corporation

                            http://ivantione.marxtar.com

                            Ivanti One Development Partner

                             

                            Try MarXtar State Management for Ivanti to Better Understand and Manage your Assets

                            • 11. Re: Batch file distribution fails
                              Schroedi Apprentice

                              Yes, Landesk loads the file into the sdmcache directory. That's what i meant, sorry.

                              Landesk has local system rights. System has full control for files, registry and so on.

                               

                              The log file says that the task was successful.

                               

                              Wed, 28 Jun 2017 15:59:40 ******* sdclient starting to process task *******
                              Wed, 28 Jun 2017 15:59:40 Task id to process: 4078
                              Wed, 28 Jun 2017 15:59:40 Command line: /policyfile="C:\ProgramData\LANDesk\Policies\CP.4078.RunNow._yh++UssRF1XV&#4747afWQL&#47YfTVxc=.xml"
                              Wed, 28 Jun 2017 15:59:40 The nostatus flag has NOT been set.
                              Wed, 28 Jun 2017 15:59:40 Core name 'DE01LDMSCORE01.truetzschler.local' obtained from active task list
                              Wed, 28 Jun 2017 15:59:40 Sending task status, cmd line -coreandip=DE01LDMSCORE01.truetzschler.local -taskid=4078 -retcode=229392442 "-ldap=CN=SU-Schröder\, Sebastian,OU=Admins,OU=DE01,OU=truetzschler,DC=truetzschler,DC=local" -pkgid=1332
                              Wed, 28 Jun 2017 15:59:42 File (FILE PATH) is not in cache
                              Wed, 28 Jun 2017 15:59:42 The nostatus flag has NOT been set.
                              Wed, 28 Jun 2017 15:59:42 Core name 'DE01LDMSCORE01.truetzschler.local' obtained from active task list
                              Wed, 28 Jun 2017 15:59:42 Sending task status, cmd line -coreandip=DE01LDMSCORE01.truetzschler.local -taskid=4078 -retcode=229392444 "-ldap=CN=SU-Schröder\, Sebastian,OU=Admins,OU=DE01,OU=truetzschler,DC=truetzschler,DC=local" -pkgid=1332
                              Wed, 28 Jun 2017 15:59:43 About to call DownloadFiles (1 files) with these settings:
                              Wed, 28 Jun 2017 15:59:43 m_allowedBandwidthWAN: 50
                              Wed, 28 Jun 2017 15:59:43 m_allowedBandwidthLAN: 75
                              Wed, 28 Jun 2017 15:59:43 m_discardPeriodSeconds: 604800
                              Wed, 28 Jun 2017 15:59:43 m_preserveDirectoryStructure: 1
                              Wed, 28 Jun 2017 15:59:43 m_bUseWanBWForPush: 0
                              Wed, 28 Jun 2017 15:59:43 m_bSynchronize: 0
                              Wed, 28 Jun 2017 15:59:43 Allowed download methods(m_downloadControl):
                              Wed, 28 Jun 2017 15:59:43 PeerOneSource
                              Wed, 28 Jun 2017 15:59:43 Peer
                              Wed, 28 Jun 2017 15:59:43 Source
                              Wed, 28 Jun 2017 15:59:43 m_preferredServerControl: AttemptPreferredServer
                              Wed, 28 Jun 2017 15:59:56 Updating system environment variable LDMS_PREFERRED_SERVER: DE01ldmscore01.TRUETZSCHLER.LOCAL
                              Wed, 28 Jun 2017 15:59:57 The nostatus flag has NOT been set.
                              Wed, 28 Jun 2017 15:59:57 Core name 'DE01LDMSCORE01.truetzschler.local' obtained from active task list
                              Wed, 28 Jun 2017 15:59:57 Sending task status, cmd line -coreandip=DE01LDMSCORE01.truetzschler.local -taskid=4078 -retcode=229392444 "-message=100%" -pkgid=1332
                              Wed, 28 Jun 2017 15:59:58 The nostatus flag has NOT been set.
                              Wed, 28 Jun 2017 15:59:58 Core name 'DE01LDMSCORE01.truetzschler.local' obtained from active task list
                              Wed, 28 Jun 2017 15:59:58 Sending task status, cmd line -coreandip=DE01LDMSCORE01.truetzschler.local -taskid=4078 -retcode=229392444 "-message=100%" -pkgid=1332
                              Wed, 28 Jun 2017 15:59:59 The nostatus flag has NOT been set.
                              Wed, 28 Jun 2017 15:59:59 Core name 'DE01LDMSCORE01.truetzschler.local' obtained from active task list
                              Wed, 28 Jun 2017 15:59:59 Sending task status, cmd line -coreandip=DE01LDMSCORE01.truetzschler.local -taskid=4078 -retcode=229392258 "-ldap=CN=SU-Schröder\, Sebastian,OU=Admins,OU=DE01,OU=truetzschler,DC=truetzschler,DC=local" -pkgid=1332
                              Wed, 28 Jun 2017 16:00:01 ExpandEnvironmentVariables Result:
                              Wed, 28 Jun 2017 16:00:01 Batch file Client Thread
                              Wed, 28 Jun 2017 16:00:01 PackagePath:  [FILE PATH]
                              Wed, 28 Jun 2017 16:00:05
                              Wed, 28 Jun 2017 16:00:05 Bat file output :

                              C:\Program Files (x86)\LANDesk\LDClient\sdmcache\LDMSSHARE\DSL\Trtzschler>call "FKT_Test_Logon.bat" 

                              Der Vorgang wurde erfolgreich beendet.

                              Der Vorgang wurde erfolgreich beendet.

                              Der Vorgang wurde erfolgreich beendet.

                               

                              Wed, 28 Jun 2017 16:00:05 Installation result DB50000
                              Wed, 28 Jun 2017 16:00:05 processing of package is complete, result 229965824 (0x0db50000 - code 0)

                              • 12. Re: Batch file distribution fails
                                MarXtar ITSMMVPGroup

                                What happens if you set the package to use a different account, such as the one you used when you were testing manually or even the logged on user (while you are logged in of course)?

                                 

                                Mark McGinn

                                MarXtar Ltd/MarXtar Corporation

                                http://ivantione.marxtar.com

                                Ivanti One Development Partner

                                 

                                Try MarXtar State Management for Ivanti to Better Understand and Manage your Assets

                                • 13. Re: Batch file distribution fails
                                  MarXtar ITSMMVPGroup

                                  Also, turn echo back on so there's more info in the results. (remember to update the package hash after saving)

                                   

                                   

                                  Mark McGinn

                                  MarXtar Ltd/MarXtar Corporation

                                  http://ivantione.marxtar.com

                                  Ivanti One Development Partner

                                   

                                  Try MarXtar State Management for Ivanti to Better Understand and Manage your Assets

                                  • 14. Re: Batch file distribution fails
                                    ahe Expert

                                    I've tested on my core (LD 9.6) and found a bug in the script. It's working on my core and W7 32 bit.

                                    I've added a logfile (automadminlogon.log) and made some entries in folder c:\temp

                                    (again a bit problems to copy source code...:-) hopefully I've copied the correct one now)

                                     

                                    @echo off
                                    SET "logfile=C:\temp\autoadminlogon.log"
                                    SET "LOGONKEY=HKLM\SOFTWARE\Test\Microsoft\Windows NT\CurrentVersion\Winlogon"
                                    >>%logfile% echo Regvalue: %LOGONKEY%
                                    reg add "%LOGONKEY%" /V "AutoAdminLogon" /t REG_SZ /D 1 /F
                                    if errorlevel 0 (
                                     set /A "code1=0"
                                     >>%logfile% echo AutoAdminLogon reg key added
                                    ) else (
                                     set /A "code1=1"
                                     >>%logfile% echo No AutoAdminLogon reg key added
                                    )
                                    reg add "%LOGONKEY%" /V "DefaultUserName" /t REG_SZ /D "Name" /F
                                    if errorlevel 0 (
                                     set /A "code2=0"
                                     >>%logfile% echo DefaultUserName reg key added
                                    ) else (
                                     set /A "code2=1"
                                     >>%logfile% echo No DefaultUserName reg key added
                                    )
                                     
                                    reg add "%LOGONKEY%" /V "DefaultPassword" /t REG_SZ /D "Password" /F
                                    if errorlevel 0 (
                                     set /A "code3=0"
                                     >>%logfile% echo DefaultPassword reg key added
                                    ) else (
                                     set /A "code3=1"
                                     >>%logfile% echo No DefaultPassword reg key added
                                    )
                                    set /A code = %code1% + %code2% + %code3%
                                    >>%logfile% echo Exit code is: %code%
                                    Exit /b %code%
                                    
                                    
                                    1 2 3 Previous Next