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

    Problem deploying cmd script with snapin

    Scheduled Pinned Locked Moved
    FOG Problems
    6
    13
    2.9k
    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.
    • Matthieu JacquartM
      Matthieu Jacquart
      last edited by

      Hi,

      I create a snapin to set a shortcut for some computers in “C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp”, which requires administrator privilege.
      I found a way to add some line to execute this cmd script with administrator privileges, and it works like a charm when I launch it form my computer.
      But when I deploy this script with fog snapin in another computer, snapin seems to deploy (o error in fog.log) but shortcut don’t appear…
      Any idea ?
      Here is the script (to clone display between monitor and videoprojector on teacher computers in classroom)

      REM --add the following to the top of your bat file--
      
      @echo off
      
      :: BatchGotAdmin
      :-------------------------------------
      REM  --> Check for permissions
      >nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
      
      REM --> If error flag set, we do not have admin.
      if '%errorlevel%' NEQ '0' (
          echo Requesting administrative privileges...
          goto UACPrompt
      ) else ( goto gotAdmin )
      
      :UACPrompt
          echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
          set params = %*:"=""
          echo UAC.ShellExecute "cmd.exe", "/c %~s0 %params%", "", "runas", 1 >> "%temp%\getadmin.vbs"
      
          "%temp%\getadmin.vbs"
          del "%temp%\getadmin.vbs"
          exit /B
      
      :gotAdmin
          pushd "%CD%"
          CD /D "%~dp0"
      :--------------------------------------
      
      @echo off
      Cls
      set SCRIPT="%TEMP%\%RANDOM%-%RANDOM%-%RANDOM%-%RANDOM%.vbs"
      echo Set oWS = WScript.CreateObject("WScript.Shell") >> %SCRIPT%
      echo sLinkFile = "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp\Clone.lnk" >> %SCRIPT%
      echo Set oLink = oWS.CreateShortcut(sLinkFile) >> %SCRIPT%
      echo oLink.TargetPath = "%windir%\System32\DisplaySwitch.exe" >> %SCRIPT%
      echo oLink.Arguments = "/clone" >> %SCRIPT%
      echo oLink.Save >> %SCRIPT%
      cscript /nologo %SCRIPT%
      del %SCRIPT%
      

      And the result in fog.log

      ------------------------------------------------------------------------------
      ---------------------------------SnapinClient---------------------------------
      ------------------------------------------------------------------------------
       14/09/2016 11:18 Client-Info Client Version: 0.11.5
       14/09/2016 11:18 Client-Info Client OS:      Windows
       14/09/2016 11:18 Client-Info Server Version: 1.3.0-RC-10
       14/09/2016 11:18 Middleware::Response Success
       14/09/2016 11:18 SnapinClient Snapin Found:
       14/09/2016 11:18 SnapinClient     ID: 1381
       14/09/2016 11:18 SnapinClient     Name: Clone
       14/09/2016 11:18 SnapinClient     Created: 2016-09-14 11:17:34
       14/09/2016 11:18 SnapinClient     Action: 
       14/09/2016 11:18 SnapinClient     Pack: False
       14/09/2016 11:18 SnapinClient     Hide: False
       14/09/2016 11:18 SnapinClient     Server: 
       14/09/2016 11:18 SnapinClient     TimeOut: 0
       14/09/2016 11:18 SnapinClient     RunWith: c:\windows\system32\cmd.exe
       14/09/2016 11:18 SnapinClient     RunWithArgs: /c
       14/09/2016 11:18 SnapinClient     Args: 
       14/09/2016 11:18 SnapinClient     File: Clone2.cmd
       14/09/2016 11:18 Middleware::Communication Download: http://192.168.10.60/fog/service/snapins.file.php?mac=E8:40:F2:3B:C7:AA&taskid=1381
       14/09/2016 11:18 SnapinClient C:\Program Files (x86)\FOG\tmp\Clone2.cmd
       14/09/2016 11:18 Bus {
        "self": true,
        "channel": "Notification",
        "data": "{\r\n  \"title\": \"Installing Clone\",\r\n  \"message\": \"Please do not shutdown until this is completed\"\r\n}"
      }
       14/09/2016 11:18 Bus Emmiting message on channel: Notification
       14/09/2016 11:18 SnapinClient Starting snapin...
       14/09/2016 11:18 SnapinClient Snapin finished
       14/09/2016 11:18 SnapinClient Return Code: 0
       14/09/2016 11:18 Bus {
        "self": true,
        "channel": "Notification",
        "data": "{\r\n  \"title\": \"Clone Installed\",\r\n  \"message\": \"Installation has finished and is now ready for use\"\r\n}"
      }
       14/09/2016 11:18 Bus Emmiting message on channel: Notification
       14/09/2016 11:18 Middleware::Communication URL: http://192.168.10.60/fog/service/snapins.checkin.php?taskid=1381&exitcode=0&mac=E8:40:F2:3B:C7:AA&newService&json
      ------------------------------------------------------------------------------
      

      Fog 1.5.9.138
      Debian 11
      Vmware ESXi

      1 Reply Last reply Reply Quote 0
      • Matthieu JacquartM
        Matthieu Jacquart
        last edited by

        Some other test :

        • double-clicking on script “Clone2.cmd” in my computer create shortcut
        • launching command “c:\windows\system32\cmd.exe /C Clone2.cmd” on my computer create shortcut
        • BUT deploying fog snapin with command “c:\windows\system32\cmd.exe /C Clone2.cmd” failed to create shortcut…

        Fog 1.5.9.138
        Debian 11
        Vmware ESXi

        1 Reply Last reply Reply Quote 0
        • Q
          Quazz Moderator
          last edited by

          Fairly certain the problem is that Snapins run under the System account, which cannot interact with the desktop, and thus you can’t “elevate” to administrator.

          Matthieu JacquartM 1 Reply Last reply Reply Quote 3
          • Matthieu JacquartM
            Matthieu Jacquart @Quazz
            last edited by

            @Quazz Oh, so it will be problematic…
            I absolutely need to force clone display on these computers, if not after deploying image principal screen is videoprojector so people can’t log on computer…

            Fog 1.5.9.138
            Debian 11
            Vmware ESXi

            Q 1 Reply Last reply Reply Quote 0
            • Q
              Quazz Moderator @Matthieu Jacquart
              last edited by Quazz

              @Matthieu-Jacquart Windows Key + P is the shortcut to switch display mode, works on login screen too.

              Not sure about how to force it using snapins though.

              1 Reply Last reply Reply Quote 1
              • J
                Joe Schmitt Senior Developer
                last edited by Joe Schmitt

                @Matthieu-Jacquart a couple things. SYSTEM sometimes won’t have the TEMP environment all variable set (yes, I know that’s weird). I also see you are using a batch script to offload to a vbs. Try removing that additional complexity by sticking to one language. Either write it in just batch or just vbs.

                Also, if its a snap in you can remove all of your UAC checks to further limit potentional points of failure.

                But as said before, it may just simply be that SYSTEM can’t clone displays. In which case you could use a snap in to write to a login script that gets run everytime a user logs in.

                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.

                1 Reply Last reply Reply Quote 1
                • Matthieu JacquartM
                  Matthieu Jacquart
                  last edited by

                  Thanks for help, finally I created a snapin which add registry key to duplicate display when someone log in, and if needed after deploying image I use Win + P key.

                  Fog 1.5.9.138
                  Debian 11
                  Vmware ESXi

                  1 Reply Last reply Reply Quote 0
                  • Jonathan CoolJ
                    Jonathan Cool
                    last edited by

                    Server :
                    FOG Version: 1.4.2 SVN 6072
                    OS: Debian 8

                    Client :
                    Service Version: SmartInstaller v0.11.12
                    OS: Win7x64 PRO

                    Description :
                    Hi,
                    I’m really sorry for the “UP” but i try to have more verbose logs for the Snapins …
                    In my case, for SnapinPack, into the fog.log, i have “just” this :

                    ------------------------------------------------------------------------------
                    ---------------------------------SnapinClient---------------------------------
                    ------------------------------------------------------------------------------
                     12/01/2018 16:07 Client-Info Client Version: 0.11.12
                     12/01/2018 16:07 Client-Info Client OS:      Windows
                     12/01/2018 16:07 Client-Info Server Version: 1.4.2
                     12/01/2018 16:07 Middleware::Response Success
                     12/01/2018 16:07 SnapinClient Running snapin algobox_64
                     12/01/2018 16:07 Middleware::Communication Download: http://xxx.xxx.xxx.xxx/fog/service/snapins.file.php?mac=xx:xx:xx:xx:xx:xx||00:00:00:00:00:00:00:E0|00:00:00:00:00:00:00:E0&taskid=xxx
                     12/01/2018 16:07 SnapinClient C:\Program Files (x86)\FOG\tmp\algobox_x64.zip
                     12/01/2018 16:07 SnapinClient Processing SnapinPack algobox_x64.zip
                     12/01/2018 16:07 SnapinClient Extracting SnapinPack
                     12/01/2018 16:07 Bus Emmiting message on channel: Notification
                     12/01/2018 16:07 SnapinClient Starting snapin
                     12/01/2018 16:07 SnapinClient Snapin finished
                     12/01/2018 16:07 SnapinClient Return Code: 0
                     12/01/2018 16:07 Bus Emmiting message on channel: Notification
                     12/01/2018 16:07 Middleware::Communication URL: ...............
                    ------------------------------------------------------------------------------```
                    

                    In your case, it’s seem to be more verbose …

                    ------------------------------------------------------------------------------
                    ---------------------------------SnapinClient---------------------------------
                    ------------------------------------------------------------------------------
                     14/09/2016 11:18 Client-Info Client Version: 0.11.5
                     14/09/2016 11:18 Client-Info Client OS:      Windows
                     14/09/2016 11:18 Client-Info Server Version: 1.3.0-RC-10
                     14/09/2016 11:18 Middleware::Response Success
                     14/09/2016 11:18 SnapinClient Snapin Found:
                     14/09/2016 11:18 SnapinClient     ID: 1381
                     14/09/2016 11:18 SnapinClient     Name: Clone
                     14/09/2016 11:18 SnapinClient     Created: 2016-09-14 11:17:34
                     14/09/2016 11:18 SnapinClient     Action: 
                     14/09/2016 11:18 SnapinClient     Pack: False
                     14/09/2016 11:18 SnapinClient     Hide: False
                     14/09/2016 11:18 SnapinClient     Server: 
                     14/09/2016 11:18 SnapinClient     TimeOut: 0
                     14/09/2016 11:18 SnapinClient     RunWith: c:\windows\system32\cmd.exe
                     14/09/2016 11:18 SnapinClient     RunWithArgs: /c
                     14/09/2016 11:18 SnapinClient     Args: 
                     14/09/2016 11:18 SnapinClient     File: Clone2.cmd
                     14/09/2016 11:18 Middleware::Communication Download: http://192.168.10.60/fog/service/snapins.file.php?mac=E8:40:F2:3B:C7:AA&taskid=1381
                     14/09/2016 11:18 SnapinClient C:\Program Files (x86)\FOG\tmp\Clone2.cmd
                     14/09/2016 11:18 Bus {
                      "self": true,
                      "channel": "Notification",
                      "data": "{\r\n  \"title\": \"Installing Clone\",\r\n  \"message\": \"Please do not shutdown until this is completed\"\r\n}"
                    }
                    

                    It’s a fog version problem or it’s just a specific configuration checked in the Global Configuration GUI ?

                    Many thanks for your help 🙂

                    My stuff :
                    Server :
                    FOG Version : Running Version 1.5.9
                    OS : Debian GNU/Linux 10
                    FOG Client Version : 0.12
                    Specifications :
                    > All images are on a Synology NAS storage : mounted with NAS_ip:/images
                    > French user :)
                    > “If everything would work the first time, what would you have learned?”
                    Challenges make knowledge growth … by George1421 ;)

                    1 Reply Last reply Reply Quote 0
                    • S
                      Sebastian Roth Moderator
                      last edited by

                      @Jonathan-Cool AFAIK it’s just the older version that had other/more debug output.

                      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

                      Wayne WorkmanW 1 Reply Last reply Reply Quote 1
                      • Wayne WorkmanW
                        Wayne Workman @Sebastian Roth
                        last edited by

                        @sebastian-roth said in Problem deploying cmd script with snapin:

                        AFAIK it’s just the older version that had other/more debug output.

                        Correct. @joe-schmitt made that change over some security concerns.

                        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
                        • Jonathan CoolJ
                          Jonathan Cool
                          last edited by

                          Thanks for reply.
                          There is a way to have more verbose snapin output with the new version of fog client ?

                          My stuff :
                          Server :
                          FOG Version : Running Version 1.5.9
                          OS : Debian GNU/Linux 10
                          FOG Client Version : 0.12
                          Specifications :
                          > All images are on a Synology NAS storage : mounted with NAS_ip:/images
                          > French user :)
                          > “If everything would work the first time, what would you have learned?”
                          Challenges make knowledge growth … by George1421 ;)

                          Wayne WorkmanW 1 Reply Last reply Reply Quote 0
                          • Wayne WorkmanW
                            Wayne Workman @Jonathan Cool
                            last edited by

                            @jonathan-cool Yes, you would just code that functionality into your script. Have it dump variables to a text file, dump errors to a text file, etc.

                            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
                            • Jonathan CoolJ
                              Jonathan Cool
                              last edited by

                              Thank you for your reply.
                              I will try that 😉

                              My stuff :
                              Server :
                              FOG Version : Running Version 1.5.9
                              OS : Debian GNU/Linux 10
                              FOG Client Version : 0.12
                              Specifications :
                              > All images are on a Synology NAS storage : mounted with NAS_ip:/images
                              > French user :)
                              > “If everything would work the first time, what would you have learned?”
                              Challenges make knowledge growth … by George1421 ;)

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

                              174

                              Online

                              12.0k

                              Users

                              17.3k

                              Topics

                              155.2k

                              Posts
                              Copyright © 2012-2024 FOG Project