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

    snapin and batch script

    Scheduled Pinned Locked Moved Unsolved
    FOG Problems
    6
    54
    19.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.
    • P
      plegrand
      last edited by plegrand

      Running Version 1.3.5
      SVN Revision: 6067
      Client 0.11.11
      Debian stable

      Hello,

      here is a piece of code which doesn’t works from snapin :

      net use * /delete /y >> %tmp%\Update_Windows7.log 2>&1
      call net use z: \\samba\wsus$ "my'password" /user:samba\administrateur >> %tmp%\Update_Windows7.log 2>&1
      

      (note the " ’ " into the password)

      This code works fine from the command line, but from snapin, the drive is displayed with a red cross as it was disconnected, and when i click on it, it says that the name or password is wrong. As i said before this code works fine from command line.

      An idea for this problem ?
      Thanks for your help

      It seams that the problem is because the script is launched as system user.
      Is there a solution to solve that ?

      P 1 Reply Last reply Reply Quote 0
      • Tom ElliottT
        Tom Elliott
        last edited by

        Seeing as you have a logfile being generated, (I’d recommend removing the %tmp% and place it somewhere implicitly for easy finding) can you try running the snapin and gather the information of the log file being generated?

        I suspect you may be correct in your thoughts but having this information would certainly help us validate and find the problem more directly.

        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 0
        • AvaryanA
          Avaryan
          last edited by Avaryan

          Assuming you’re deploying to a Windows PC.

          Perhaps convert to PowerShell to mount/unmount the network share? It might work better.

          Example for mounting/unmounting shares.

          $Username = "Domain\Username"
          $Password = "Password" | ConvertTo-SecureString -AsPlainText -Force
          $Credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $Username, $Password
          # Add share.
          New-PSDrive -Name "MyShare" -PSProvider FileSystem -Root \\ShareName\SomeFolder -Credential $Credential
          # Remove share.
          Remove-PSDrive -Name "MyShare"
          
          1 Reply Last reply Reply Quote 0
          • Tom ElliottT
            Tom Elliott
            last edited by

            I’m trying to understand more and more what’s actually happening.

            Is the snapin simply making a mount? This wouldn’t work as it would map the drive under the System user, not available to all users as I imagine you’re hoping for.

            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 0
            • Tom ElliottT
              Tom Elliott
              last edited by

              Essentially, the reason why the “red x” happens is because System user is who mounted the point, and the permissions are not available to the user you’re actually logged in under. If you need a “global” mount of a drive, this would be more readily handled using GPO’s, not fog snapins. While I’m sure it “could” be handled via a snapin, i think such a thing is out of scope for the FOG Client.

              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

              P Wayne WorkmanW 2 Replies Last reply Reply Quote 0
              • P
                plegrand @Tom Elliott
                last edited by

                @Tom-Elliott I understand that is System User who mounted the point but i’m loged as administrator. It’s not enough to use the share ?
                I don’t use GPO’s.
                Have you got an idea on how mount a share via snapin ?

                @Avaryan I think it will be the same with power shell

                thanks for your help

                Tom ElliottT 1 Reply Last reply Reply Quote 0
                • Tom ElliottT
                  Tom Elliott @plegrand
                  last edited by

                  @plegrand The problem is the credentials are with the user who established the mount, not a “global” setup.

                  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

                  P 1 Reply Last reply Reply Quote 0
                  • AvaryanA
                    Avaryan
                    last edited by

                    Yes, the result was the same via PowerShell. I just tested it.

                    Do you need users to be able to access the drive? Or do you just need to mount the drive to do some action and then unmount the drive?

                    P 1 Reply Last reply Reply Quote 0
                    • P
                      plegrand @Tom Elliott
                      last edited by

                      @Tom-Elliott the user who established the mount => You means system user ?

                      AvaryanA Tom ElliottT 2 Replies Last reply Reply Quote 0
                      • AvaryanA
                        Avaryan @plegrand
                        last edited by

                        @plegrand said in snapin and batch script:

                        @Tom-Elliott the user who established the mount => You means system user ?

                        FOG runs the snapin as the local SYSTEM account. So the drive is getting mounted under that account and not under any useable user.

                        Tom ElliottT 1 Reply Last reply Reply Quote 0
                        • Tom ElliottT
                          Tom Elliott @plegrand
                          last edited by

                          @plegrand Yes.

                          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 0
                          • P
                            plegrand @Avaryan
                            last edited by

                            @Avaryan it’s for use WsusOffline which is installed on a samba share \samba\wsus
                            then i need to mount the wsus share , launch a command (wsus command) dnd then umount share.

                            Tom ElliottT AvaryanA 2 Replies Last reply Reply Quote 0
                            • Tom ElliottT
                              Tom Elliott @Avaryan
                              last edited by

                              @Avaryan Slight correction, as the drive being mounted is “system wide” it will “appear” as the drive letter being mounted, but the credentials are not available to any user but the one who established the mount.

                              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

                              P 1 Reply Last reply Reply Quote 0
                              • P
                                plegrand @Tom Elliott
                                last edited by

                                @Tom-Elliott OK i understand
                                Then no solution ?

                                1 Reply Last reply Reply Quote 0
                                • Tom ElliottT
                                  Tom Elliott @plegrand
                                  last edited by

                                  @plegrand So if you mount the drive, and in the same script run the action needed, things should work. You wouldn’t be able to make the mount->use another user to perform the action->then unmount.

                                  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

                                  P 1 Reply Last reply Reply Quote 0
                                  • AvaryanA
                                    Avaryan @plegrand
                                    last edited by Avaryan

                                    @plegrand said in snapin and batch script:

                                    @Avaryan it’s for use WsusOffline which is installed on a samba share \samba\wsus
                                    then i need to mount the wsus share , launch a command (wsus command) dnd then umount share.

                                    Ok. That should be possible since the local users don’t need to access the mount. Should be pretty easy in PowerShell. I don’t know how to do it other ways, lol.

                                    $Username = "Domain\User"
                                    $Password = "Password" | ConvertTo-SecureString -AsPlainText -Force
                                    $Credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $Username, $Password
                                    # Add share.
                                    New-PSDrive -Name "MyShare" -PSProvider FileSystem -Root \\ShareName\ -Credential $Credential
                                    
                                    # Do something...
                                    # More somethings...
                                    
                                    Remove-PSDrive -Name "MyShare"
                                    
                                    P 1 Reply Last reply Reply Quote 0
                                    • P
                                      plegrand @Tom Elliott
                                      last edited by plegrand

                                      @Tom-Elliott Here is what i need to do and which doesn’ works :

                                      net use * /delete /y >> %tmp%\Update_Windows7.log 2>&1
                                      net use z: \\samba\wsus$ "my'password" /user:samba\administrateur >> %tmp%\Update_Windows7.log 2>&1
                                      z:\wsusoffline\client\UpdateInstaller.exe >> %tmp%\Update_Windows7.log 2>&1
                                      net use /delete * /y >> %tmp%\Update_Windows7.log 2>&1
                                      

                                      UpdateInstaller.exe isn’t launched

                                      Tom ElliottT 1 Reply Last reply Reply Quote 0
                                      • P
                                        plegrand @Avaryan
                                        last edited by

                                        @Avaryan As you can see , i need to mount the share and execute a command which is inside this share…
                                        Then i thin it’s not possible ?

                                        AvaryanA 1 Reply Last reply Reply Quote 0
                                        • AvaryanA
                                          Avaryan @plegrand
                                          last edited by Avaryan

                                          @plegrand said in snapin and batch script:

                                          @Avaryan As you can see , i need to mount the share and execute a command which is inside this share…
                                          Then i thin it’s not possible ?

                                          Should be possible.

                                          $Username = "samba\administrator"
                                          $Password = "my'password" | ConvertTo-SecureString -AsPlainText -Force
                                          $Credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $Username, $Password
                                          
                                          New-PSDrive -Name "Samba" -PSProvider FileSystem -Root '\\samba\wsus$' -Credential $Credential
                                          $UpdateInstaller = Get-ChildItem -Path "Samba:\wsusoffline\client\" | Where-Object -Property Name -EQ "UpdateInstaller.exe"
                                          Start-Process -FilePath $UpdateInstaller.FullName -Wait
                                          Remove-PSDrive -Name "Samba"
                                          

                                          Depending on how large the UpdateInstaller.exe is and how many devices you are doing at once, it might be better to have this copy it over and run locally.

                                          P 2 Replies Last reply Reply Quote 0
                                          • Tom ElliottT
                                            Tom Elliott @plegrand
                                            last edited by

                                            @plegrand Does the UpdateInstaller.exe require User input?

                                            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 0
                                            • 1
                                            • 2
                                            • 3
                                            • 1 / 3
                                            • First post
                                              Last post

                                            195

                                            Online

                                            12.0k

                                            Users

                                            17.3k

                                            Topics

                                            155.2k

                                            Posts
                                            Copyright © 2012-2024 FOG Project