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

    Run script after OOBE

    Scheduled Pinned Locked Moved Unsolved
    Windows Problems
    2
    6
    141
    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.
    • R
      robertkwild
      last edited by

      ok ive done this and it works

      <component name="Microsoft-Windows-Deployment" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="NonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
                  <RunSynchronous>
                      <RunSynchronousCommand wcm:action="add">
                          <Description>firstlogon</Description>
                          <Order>1</Order>
                          <Path>C:\Users\admin\sysprep\firstlogon.bat</Path>
                      </RunSynchronousCommand>
                  </RunSynchronous>
              </component>
      

      and my bat is just this

      @echo off
      
      C:\Users\admin\sysprep\SophosSetup.exe --quiet
      
      rmdir /Q /S C:\Users\admin\sysprep
      

      this works but when i try to run a powershell command that needs admin it cant do it ie

      powershell.exe -ExecutionPolicy Bypass -File path-to-ps1

      in there i just have this

      Set-LocalUser -Name “user” -PasswordNeverExpires $true

      but everytime after the sysprep and it loads into windows it hasnt done it as it hasnt got admin privs

      so how come cmd had admin but ps1 doesnt?

      any idea please

      thanks,
      rob

      R R 2 Replies Last reply Reply Quote 0
      • R
        rodluz Developer @robertkwild
        last edited by

        @robertkwild This isn’t a FOG issue at all but I would look into running your sysprep scripts in the SetupComplete.cmd file. I’ve never had any issues with admin privileges when running powershell scripts from it.

        https://learn.microsoft.com/en-us/windows-hardware/manufacture/desktop/add-a-custom-script-to-windows-setup?view=windows-11

        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

        R 1 Reply Last reply Reply Quote 0
        • R rodluz moved this topic from FOG Problems
        • R
          robertkwild @rodluz
          last edited by

          @rodluz thanks but doesnt this need a VL key to run those scripts?

          R 1 Reply Last reply Reply Quote 0
          • R
            rodluz Developer @robertkwild
            last edited by

            @robertkwild I don’t think so. A couple years ago, I imaged a Windows 11 Home machine without any license key and used the SetupComplete.cmd script without any issue.
            It won’t run it if using an OEM key, though.

            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

            R 1 Reply Last reply Reply Quote 0
            • R
              robertkwild @rodluz
              last edited by

              @rodluz

              solved…

              https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2012-R2-and-2012/dn789190(v=ws.11)

              i used a computer startup script

              script name:
              C:\Users\admin\sysprep\firstlogon.ps1

              script parameters:
              powershell -ep Bypass

              and heres the script (just made a rough one to test and every command ran as when i logged in after the pc syspreped all commands worked)

              start-process 'C:\Users\admin\sysprep\Firefox Setup 138.0.exe' /S -wait
              
              Remove-ItemProperty -Path "HKLM:\SOFTWARE\Wow6432Node\AdventNet\DesktopCentral\DCAgent\" -Name "ImagedComputer" -Force
              
              Remove-Item -Path "HKLM:\SOFTWARE\Wow6432Node\AdventNet\DesktopCentral\DCAgent\SystemDetails" -Force
              
              Set-LocalUser -Name "user01" -PasswordNeverExpires $true
              Set-LocalUser -Name "it" -PasswordNeverExpires $true
              
              remove-item -path C:\Users\admin\sysprep -recurse -force
              
              
              1 Reply Last reply Reply Quote 0
              • R
                robertkwild @robertkwild
                last edited by

                @rodluz

                ok scrap the local GPO done this and it works

                reg add HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnce /v firstlogon /t REG_SZ /d powershell -noexit -ep bypass c:\users\admin\sysprep\firstlogon.ps1 /f
                
                1 Reply Last reply Reply Quote 0
                • 1 / 1
                • First post
                  Last post

                256

                Online

                12.0k

                Users

                17.3k

                Topics

                155.2k

                Posts
                Copyright © 2012-2024 FOG Project