• Recent
  • Unsolved
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Register
  • Login
  • Recent
  • Unsolved
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Register
  • Login

executing batch file from snapin

Scheduled Pinned Locked Moved
General
5
18
8.5k
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W
    Wayne Workman @Olduser
    last edited by Jan 6, 2017, 2:01 PM

    @Olduser As @Joe-Schmitt and others have said, C:\program Files\FOG\tmp is temporary.

    Files in that directory are not permanent. As soon as the snapin is complete, files in there are immediately deleted forever. Gone. Purged.

    Please post a copy of your script so we can help you more.

    Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG!
    Daily Clean Installation Results:
    https://fogtesting.fogproject.us/
    FOG Reporting:
    https://fog-external-reporting-results.fogproject.us/

    1 Reply Last reply Reply Quote 0
    • O
      Olduser
      last edited by Jan 6, 2017, 3:02 PM

      Tom,

      Thank You very much for reply. I am also trying to figure out why snapin will install the batch script sometimes and other time nothing happens. I see a message that "Test installed " on taskbar but when I go to C:\Program Files\FOG\tmp, it is empty. If I run script manually, it run without any problem. I see copy file in C:\Temp directory.

      The batch script does this:0_1483714596462_fogforum.png

      Thanks,
      Olduser

      G 1 Reply Last reply Jan 6, 2017, 3:54 PM Reply Quote 0
      • G
        george1421 Moderator @Olduser
        last edited by george1421 Jan 6, 2017, 9:55 AM Jan 6, 2017, 3:54 PM

        @Olduser If it was me, I would create some conditional tests.

        Does the S: drive exist
        Does the user account running this batch copy script have user rights to S:
        Does the path S:\PAT exist
        Does the file tdpunt.bat exist in the path S:\PAT
        Does the C:\Temp path exist, if not then create it
        Write the negative results of your tests to a log file in C:\Temp to help you figure out what went wrong.

        Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG!

        1 Reply Last reply Reply Quote 3
        • O
          Olduser
          last edited by Tom Elliott Jan 6, 2017, 9:48 PM Jan 6, 2017, 4:55 PM

          Tom,

          I am also pasting fog log below:

          -----------------------------------------------------------------------------
          ---------------------------------SnapinClient---------------------------------
          ------------------------------------------------------------------------------
           1/6/2017 11:32 AM Client-Info Client Version: 0.11.7
           1/6/2017 11:32 AM Client-Info Client OS:      Windows
           1/6/2017 11:32 AM Client-Info Server Version: 1.3.0-RC-37
           1/6/2017 11:32 AM Middleware::Response Success
           1/6/2017 11:32 AM SnapinClient Snapin Found:
           1/6/2017 11:32 AM SnapinClient     ID: 291
           1/6/2017 11:32 AM SnapinClient     Name: test
           1/6/2017 11:32 AM SnapinClient     Created: 2017-01-06 16:32:21
           1/6/2017 11:32 AM SnapinClient     Action: 
           1/6/2017 11:32 AM SnapinClient     Pack: False
           1/6/2017 11:32 AM SnapinClient     Hide: False
           1/6/2017 11:32 AM SnapinClient     Server: 
           1/6/2017 11:32 AM SnapinClient     TimeOut: 0
           1/6/2017 11:32 AM SnapinClient     RunWith: cmd.exe
           1/6/2017 11:32 AM SnapinClient     RunWithArgs: /c
           1/6/2017 11:32 AM SnapinClient     Args: 
           1/6/2017 11:32 AM SnapinClient     File: test.bat
           1/6/2017 11:32 AM Middleware::Communication Download: http://10.106.12.197/fog/service/snapins.file.php?mac=18:03:73:E6:62:43||00:00:00:00:00:00:00:E0&taskid=291
           1/6/2017 11:32 AM SnapinClient C:\Program Files\FOG\tmp\test.bat
           1/6/2017 11:32 AM Bus {
            "self": true,
            "channel": "Notification",
            "data": "{\r\n  \"title\": \"Installing test\",\r\n  \"message\": \"Please do not shutdown until this is completed\"\r\n}"
          }
           1/6/2017 11:32 AM Bus Emmiting message on channel: Notification
           1/6/2017 11:32 AM SnapinClient Starting snapin...
           1/6/2017 11:32 AM SnapinClient Snapin finished
           1/6/2017 11:32 AM SnapinClient Return Code: 0
           1/6/2017 11:32 AM Bus {
            "self": true,
            "channel": "Notification",
            "data": "{\r\n  \"title\": \"test Installed\",\r\n  \"message\": \"Installation has finished and is now ready for use\"\r\n}"
          }
           1/6/2017 11:32 AM Bus Emmiting message on channel: Notification
           1/6/2017 11:32 AM Middleware::Communication URL: http://10.106.12.197/fog/service/snapins.checkin.php?taskid=291&exitcode=0&mac=18:03:73:E6:62:43||00:00:00:00:00:00:00:E0&newService&json
          ------------------------------------------------------------------------------
          
          1 Reply Last reply Reply Quote 0
          • J
            JJ Fullmer Testers
            last edited by Jan 6, 2017, 7:32 PM

            I would suggest using the full path of the file in your batch script instead of changing the directory.
            And when I say full path, I mean the true full path, not the mounted S:\ drive.
            Even if S:\ is being mounted by active directory or is a mapped drive as part of your image, I would still suggest using the full network/unc path.
            I would also suggest mounting it with net use and a username and password. This will ensure the system account that the Fog Service uses has access to the files you want
            I would also add some logging and other error preventions.

            i.e. if S:\ was mapped to \FileServer\Share …

            @ECHO off
            
            echo. Create variables to make scripting easier
            set sharePath=\\FileServer\Share\Pat
            
            echo. Mount S drive path, replace username and password with share credentials. 
            echo. If share is public omit the /USER parameter and everything after it
            
            
            net use %sharePath% /USER:username password
            
            echo. make sure destination exists, create it if it doesn't
            if not exist C:\temp mkdir C:\temp
            
            echo. copy each file, add /Y to overwrite without any prompt
            echo. copying tdpunt...
            copy /Y %sharePath%\tdpunt.bat C:\temp\ > C:\temp\tdpunt-bat-Copy.log
            echo. copying tundpt.exe...
            copy /Y %sharePath%\tundpt.exe C:\temp\ > C:\temp\tundpt-exe-Copy.log
            
            echo. Done!
            
            exit
            
            

            Use that and then see if the .log files show up after deploying the snapin.

            Also, in the web gui snapin config, you should take out the /qn that does nothing.
            The snapin arguments section is for custom arguments that you have in your script. Your script doesn’t do anything with the /qn and it could cause issues. The /c parameter is passed to the cmd.exe command which tells cmd.exe to open a prompt, run the command, and then close.
            If you had a line in your script like this

            if "%1" == "/qn" (
                echo. hey look a parameter, lets do something since it's there!
            )
            

            then the /qn would have a point.

            Hope that helps a bit.

            Thanks,
            -JJ

            Have you tried the FogApi powershell module? It's pretty cool IMHO
            https://github.com/darksidemilk/FogApi
            https://fogapi.readthedocs.io/en/latest/
            https://www.powershellgallery.com/packages/FogApi
            https://forums.fogproject.org/topic/12026/powershell-api-module

            G 2 Replies Last reply Jan 6, 2017, 7:40 PM Reply Quote 4
            • G
              george1421 Moderator @JJ Fullmer
              last edited by george1421 Jan 6, 2017, 1:41 PM Jan 6, 2017, 7:40 PM

              @JJ-Fullmer Well done!! I wish I could upvote your post more that just +1.

              Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG!

              J 2 Replies Last reply Jan 6, 2017, 7:42 PM Reply Quote 1
              • J
                JJ Fullmer Testers @george1421
                last edited by Jan 6, 2017, 7:42 PM

                @george1421 Oh darn, I meant to also mention you in that comment saying that you were right and I was taking it a step further. So pretend I did that, and no I don’t know what an edit button is.

                Have you tried the FogApi powershell module? It's pretty cool IMHO
                https://github.com/darksidemilk/FogApi
                https://fogapi.readthedocs.io/en/latest/
                https://www.powershellgallery.com/packages/FogApi
                https://forums.fogproject.org/topic/12026/powershell-api-module

                1 Reply Last reply Reply Quote 0
                • J
                  JJ Fullmer Testers @george1421
                  last edited by Jan 6, 2017, 7:42 PM

                  @george1421 And thank you good sir.

                  Have you tried the FogApi powershell module? It's pretty cool IMHO
                  https://github.com/darksidemilk/FogApi
                  https://fogapi.readthedocs.io/en/latest/
                  https://www.powershellgallery.com/packages/FogApi
                  https://forums.fogproject.org/topic/12026/powershell-api-module

                  1 Reply Last reply Reply Quote 0
                  • G
                    george1421 Moderator @JJ Fullmer
                    last edited by george1421 Jan 6, 2017, 1:48 PM Jan 6, 2017, 7:47 PM

                    @JJ-Fullmer The only tweak I might suggest to your excellent code is that you could make the password for the share a batch variable like %1 and then pass that from answer from FOG so the password never exists in the batch script at all in case it was left behind for some reason after the snapin exited. It would be passed from FOG (assuming you can add switch variables inside the snapin setup). That part I don’t know because I don’t personally use snapins. Either way you could probably call the batch file with cmd.exe /c test.bat password and that should do it.

                    Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG!

                    1 Reply Last reply Reply Quote 0
                    • T
                      Tom Elliott
                      last edited by Jan 7, 2017, 3:46 AM

                      TL;DR; Looking in the FOG installation tmp folder for where your script is running is not how your script is logically written. You should check the C:\Temp folder. (Maybe it’s not doing what you want because the C:\Temp folder doesn’t event exist?)

                      I think this is what’s interesting to me.

                      First, the messages of:
                      @Olduser said in executing batch file from snapin:

                      but when I go to C:\Program Files\FOG\tmp, it is empty. If I run script manually, it run without any problem. I see copy file in C:\Temp directory.

                      You’re confusing yourself, as well as us, with the insistence of when i go to C:\Program Files\FOG\tmp

                      As already stated numerous times, the C:\Program Files\FOG\tmp (or C:\Program Files (x86)\FOG\tmp) is the temporary holding point for the snapin being downloaded (then executed). Once the snapin is complete with installation the files used are cleaned up. This means the file will no longer exist.

                      The Confusion, I believe, is you may be checking the wrong place to see if the snapin did, or didn’t, work properly. Items 1-2 are kind of hand-in-hand.

                      1. Does the C:\Temp folder exist on the system? (Maybe before you try copying you should add mkdir %SYSTEMDRIVE%\Temp)
                      2. Is 😄 the drive letter for your OS (I’d recommend changing the 😄 portion to %SYSTEMDRIVE%)
                      3. When checking if the snapin did what you want make sure you’re looking in the place the script is trying to write to. (In your case it’s currently C:\Temp) It will not exist in the FOG\tmp folder except when it’s downloading and executing. That and your script is NOT writing anything to the FOG\tmp.

                      Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG! Get in contact with me (chat bubble in the top right corner) if you want to join in.

                      Web GUI issue? Please check apache error (debian/ubuntu: /var/log/apache2/error.log, centos/fedora/rhel: /var/log/httpd/error_log) and php-fpm log (/var/log/php*-fpm.log)

                      Please support FOG if you like it: https://wiki.fogproject.org/wiki/index.php/Support_FOG

                      1 Reply Last reply Reply Quote 1
                      • O
                        Olduser
                        last edited by Jan 9, 2017, 5:12 PM

                        Tom & JJ,

                        Thank you for your help. I will make changes to batch script and add full path to networkdrive and modify my script as you both suggested. On last Friday before going home. I un-installed the FOG client on PC , re-installed it and my batch script was there. I waited for about 1/2 hours to see if this file gets deleted from C:\Program Files\FOG\temp folder but it was still there. I will follow your suggestions and let to you know.

                        Thanks,
                        Olduser

                        1 Reply Last reply Reply Quote 0
                        • 1 / 1
                        1 / 1
                        • First post
                          17/18
                          Last post

                        129

                        Online

                        12.1k

                        Users

                        17.3k

                        Topics

                        155.3k

                        Posts
                        Copyright © 2012-2024 FOG Project