Troubleshooting snapins not deploying. Error code 255
-
Fog Version 8537
So I have quite a few scripts I’ve used without issue as snapins in the past. However I just made some improvements that seem to have caused them to stop working as fog snapins. I made it so all my scripts can use a bunch of shared function scripts instead of copying the same functions over and over again. And those shared functions are in a network drive.
When I run this manually it works perfectly fine. All the shared function scripts are run with the
CALL
command so if just goes right back to the original script once it’s done and looks like it’s all running one script when you watch it in the command line.But when I run it with fog. It deploys it says it starts and finishes in a matter of seconds. I check the log and all I see is
7/13/2016 10:21 AM SnapinClient ID: 1079 7/13/2016 10:21 AM SnapinClient Name: Office 2010 Standard 7/13/2016 10:21 AM SnapinClient Created: 2016-07-13 10:20:42 7/13/2016 10:21 AM SnapinClient Action: 7/13/2016 10:21 AM SnapinClient Hide: False 7/13/2016 10:21 AM SnapinClient TimeOut: 0 7/13/2016 10:21 AM SnapinClient RunWith: 7/13/2016 10:21 AM SnapinClient RunWithArgs: 7/13/2016 10:21 AM SnapinClient File: Office2010.bat 7/13/2016 10:21 AM SnapinClient Args: Standard 7/13/2016 10:21 AM Middleware::Communication Download: http://fogserver/fog/service/snapins.file.php?mac=78:E7:D1:C6:E2:00||00:00:00:00:00:00:00:E0&taskid=1079 7/13/2016 10:21 AM SnapinClient C:\Program Files (x86)\FOG\tmp\Office2010.bat 7/13/2016 10:21 AM Bus { "self": true, "channel": "Notification", "data": "{\r\n \"title\": \"Installing Office 2010 Standard\",\r\n \"message\": \"Please do not shutdown until this is completed\"\r\n}" } 7/13/2016 10:21 AM Bus Emmiting message on channel: Notification 7/13/2016 10:21 AM SnapinClient Starting snapin... 7/13/2016 10:21 AM SnapinClient Snapin finished 7/13/2016 10:21 AM SnapinClient Return Code: 255 7/13/2016 10:21 AM Bus { "self": true, "channel": "Notification", "data": "{\r\n \"title\": \"Office 2010 Standard Installed\",\r\n \"message\": \"Installation has finished and is now ready for use\"\r\n}" } 7/13/2016 10:21 AM Bus Emmiting message on channel: Notification 7/13/2016 10:21 AM Middleware::Communication URL: http://fogserver/fog/service/snapins.checkin.php?taskid=1079&exitcode=255&mac=78:E7:D1:C6:E2:00||00:00:00:00:00:00:00:E0&newService&json ------------------------------------------------------------------------------
I also tried making this into a snapinpack by making the needed edits for it to find the shared-functions in the fog snapin path but still had the same problem.
So here’s an example of my office 2010 script that worked before when it was all in one script but now doesn’t work so much.
The main script
::----------------------------------------------------------------------------- :: Arrowhead Dental Lab admin_scripts :: Script Name: Office2010 :: Original Author: jfullmer :: Created Date: 2016-04-28 16:22:24 :: Last Updated Date: 2016-07-13 10:24:19 :: Update Author: jfullmer :: Version: 3.4 ::----------------------------------------------------------------------------- @ECHO OFF REM This script takes one arguement for the version of office... rem Relates to Jira issue FOG-155 rem Pass arguement of ProPlus or Standard for the cooresponding version of office if NOT "%1"=="" ( set version=%1 ) else ( set version=Standard ) call :main rem @pause ::Uncomment this to enable debugging mode GOTO :EOF :main REM Function to call other functions and run the installation process rem Set variables based on version or prompt for version if %version%==ProPlus ( call :setProPlusVars ) else if %version%==Standard ( call :setStandardVars ) else ( set /p version="Please specify version, Standard or ProPlus...: " goto :main ) call :setVars call :funcHead "Welcome to the %programName% installer!" call :install call :activate call :func copyShortcuts.bat "Microsoft Office" %programCat% "%shortcuts%" call :func delShare.bat B: EXIT /B :setStandardVars call :funcHead "Setting standard variables" set programName=Microsoft Office 2010 Standard set root=\\ITNas\ITBackups\Applications\Microsoft Office\Standard-x86-wSP1 EXIT /B :setProPlusVars call :funcHead "Setting proplus variables" set programName=Microsoft Office 2010 Professional Plus set root=\\ITNas\ITBackups\Applications\Microsoft Office\ProPlus-x86-wSP1 EXIT /B :setVars call :funcHead "Setting script variables" set Lroot=C:\office2010sp1 set programCat=Internet-And-Office set shortcuts=C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Microsoft Office rem Create variables for running Office Service Protection Platform set osppPath="C:\Program Files (x86)\Microsoft Office\Office14\OSPP.VBS" set ospp=cscript %osppPath% echo. Done setting script variables! echo. Mounting installer directory call :func mntShare.bat \\ITNas\ITBackups B EXIT /B :install call :funcHead "Installing %programName%" echo. make the directory first mkdir %Lroot% echo. Copy Install files locally... call :func copyDir.bat "Office-2010-installer" "%root%" %Lroot% MirXiso echo. Installing Office 2010 %version%... %Lroot%\setup.exe /adminfile %Lroot%\adminFile.msp call :funcHead "Installing Service Pack 2..." "%Lroot%\Office-2010-sp2.exe" /log:C:\officesp2.log /quiet /norestart echo. Deleting copied files... cd C:\ rmdir %Lroot% /S /Q echo. Done installing %programName%! EXIT /B :activate call :funcHead "Activating Office 2010" echo. Stopping office activation service... net stop osppsvc echo. set the kms host... %ospp% /sethst:kms.arrowheaddental.com echo. set the kms port... %ospp% /setprt:1688 echo. activate office 2010 via kms host... %ospp% /act > C:\OfficeActivation.log echo. Start office activation service net start osppsvc EXIT /B :func rem Function to call external shared functions call :funcHead "Calling %~1 and waiting" set includes=\\arrowfs3\scripts\Shared-Functions set params="%~2" "%~3" "%~4" "%~5" "%~6" "%~7" "%~8" "%~9" rem echo CALL %includes%\%~1 %params% ::Uncomment to enable debugging echo of all passed parameters CALL %includes%\%~1 %params% rem If the function called was copyself and the script isn't being run from C:\ then the script has already run and should exit if %~1==copySelf.bat if NOT %~dp0==C:\ GOTO :EOF EXIT /B :dots REM just echoing dots in a Function instead of copy pasting them so that it's consistent echo ...................................................................... EXIT /B :funcHead REM A simple function for displaying a consistent header at the start of functions call :dots echo. %~1 call :dots rem @pause ::Uncomment to enable debugging mode for script EXIT /B
Shared Functions used
Copy Dir
::----------------------------------------------------------------------------- :: Arrowhead Dental Lab admin_scripts :: Script Name: copyDir :: Original Author: jfullmer :: Created Date: 2016-06-27 08:53:06 :: Last Updated Date: 2016-07-08 14:04:09 :: Update Author: jfullmer :: Version: 1.7 ::----------------------------------------------------------------------------- @ECHO OFF REM Function inputs - 1 = display of what is copying and log file title 2 = source folder 3 = destination folder 4=Type REM This Function simply displays what you're copying and copies it. Did a Function to have less REM copy paste of command line options and have cleaner code. REM Note that when calling the Function all passed parameters should be encased in double quotes REM otherwise ROBOCOPY won't read the directories as seperate REM ROBOCOPY or robust copy, is a tool for copying directories or files in windows command line REM The syntax is ROBOCOPY sourceFolder DestFolder options REM the options used make it so a mirrored version of the source and its subdirectories are copied REM to the destination with 64 threads (64 files at once) overwriting existin files retrying any failed files REM only once after 1 second of waiting and all logged to a given logfile REM /S - subdirectories /MIR - mirror /MT:64 - multithreaded copy with 64 threads, i.e. 64 files at a time instead of 1. REM /LOG - output to logfile instead of console, ROBOCOPY /? says this provides better performance in multithreaded mode REM /R:1 retry on error once (default is 1 million) W:1 - wait one second between retry on error (default is 30 seconds) / REM /XJ - exclude junction points (take out for shortcut files) /XA:SH excludes files with windows system attribute REM /ZB first attempts to copy files in restartable mode (as in you can restart copying where you left off) and if it fails retries in backup mode set var1=%1 set var2=%2 set var3=%3 set var4=%4 set log=%var1:"=% set src=%var2:"=% set dst=%var3:"=% set typ=%var4:"=% rem Set params, default is Mir if NOT defined %var4% ( call :CASE_Mir ) else ( call :CASE_%typ% ) rem Copy the dir with the set params call :copyDir rem GOTO :EOF GOTO :EOF rem Copydir with Mirror :copyDir call :funcHead "Copying %typ% Dirs" echo. Copying %log%... ROBOCOPY "%src%" "%dst%" /LOG:"C:\%log%.log" /R:1 /W:1 %params% echo. Done Copying %log% EXIT /B :CASE_Mir rem Sets Mirror with multithreaded at 32, exc set params=/ZB /S /MIR /MT:64 EXIT /B :CASE_MirX rem Mirror excluding junction points and system/hiddent files set params=/ZB /S /MIR /MT:64 /XA:SH /XJ EXIT /B :CASE_MirXiso rem Sets Mirror with multithreaded at 32, exc set params=/ZB /S /MIR /MT:64 /XA:SH /XF *.iso EXIT /B :CASE_MirIS rem Sets Mirror with multithreaded at 32, Includes and overwrites any same files instead of deleting them set params=/ZB /S /MIR /MT:64 /XA:SH /IS EXIT /B :CASE_Bck rem Sets parameters for backing up user files set params=/ZB /S /MIR /MT:8 /XD App* /XD *drive /XD DropBox /XD odrive /XD *min /XD "Default User*" /XD Default* /XD Administrator* /XD NetworkService* /XD ".NET*" /XD adl* /XD QBD* /XD Updatus* /XD spiceworks* /XJ /XA:SH /XF ntuser* /XF *.ost /XF *.lnk EXIT /B :CASE_Rst rem Sets parameters for restoring user files set params=/E /MT:8 /XD App* /XD *drive /XD DropBox /XD odrive /XJ /XA:SH /XF ntuser* /XX EXIT /B :CASE_Mv rem Sets parameters for moving local files set params=/E /MT:128 /MOVE /XD App* /XD *drive /XD DropBox /XD odrive /XJ /XA:SH /XF ntuser* /XX EXIT /B :CASE_Pf rem set params for copying custom program files set params=/E /IS /MT:64 /XA:SH EXIT /B :CASE_XP rem Sets params and runs XP version of ROBOCOPY and leaves function set params=/ZB /S /MIR /XD App* /XD *drive /XD DropBox /XD odrive /XD "Cookies*" /XD "*IE*" /XD "*Hood" /XD "Start Menu*" /XD "Templates*" /XD "Recent*" /XD "SendTo*" /XD "Local*" /XD *min /XF tokens.dat /XF cache.dat /XD "Default User*" /XD Default* /XD Administrator* /XD NetworkService* /XD Public* /XD ".NET*" /XD adl* /XD QBD* /XD Updatus* /XD spiceworks* /XJ /XA:SH /XF ntuser* /XF *.ost /XF *.lnk call :funcHead "Copying %typ% Dirs" echo. Copying %log%... C:\robocopy.exe "%src%" "%dst%" /LOG:"C:\%log%.log" /R:1 /W:1 %params% echo. Done Copying %log% GOTO :EOF EXIT /B :dots REM just echoing dots in a Function instead of copy pasting them so that it's consistent echo ...................................................................... EXIT /B :funcHead REM A simple function for displaying a consistent header at the start of functions call :dots echo. %~1 call :dots rem @pause ::Uncomment to enable debugging mode for script EXIT /B
CopyShortcuts
::----------------------------------------------------------------------------- :: Arrowhead Dental Lab admin_scripts :: Script Name: copyShortcuts :: Original Author: jfullmer :: Created Date: 2016-06-24 15:37:20 :: Last Updated Date: 2016-07-11 12:28:57 :: Update Author: jfullmer :: Version: 1.8 ::----------------------------------------------------------------------------- @ECHO OFF rem Set each var to the passed parameter minus the "'s' set var1=%1 set var2=%2 set var3=%3 set programName=%var1:"=% set programCat=%var2:"=% set shortcuts=%var3:"=% call :main rem GOTO :EOF GOTO :EOF :main REM this is a function to copy/move any shortcuts to the organized folders REM I reccomend making a shortcut directory in the self extracting archive so that you only need this one command set startMenu=C:\ProgramData\Microsoft\Windows\Start Menu\Programs\%programCat% set curUserStartMenu=AppData\Roaming\Microsoft\Windows\Start Menu\Programs\%programCat% set startFolder=%startMenu%\%programName% set curUserStartFolder=%curUserStartMenu%\%programName% set includes=\\arrowfs3\scripts\Shared-Functions call :funcHead "Organizing Start Menu shortcuts" setlocal enableextensions enabledelayedexpansion echo. Create shared shortcut dirs... echo. Creating "%startMenu%" and "%startFolder%" if not exist "%startMenu%" mkdir "%startMenu%" if not exist "%startFolder%" mkdir "%startFolder%" echo. Copy to shared startmenu... call :func copyDir.bat "Start menu shortcuts" "%shortcuts%" "%startFolder%" Mir echo. Copy to each user's start menu... for /F %%i in ('dir /a:-s /b C:\Users') DO ( if not %%i==Public ( echo. create %%i shortcut dirs... if not exist "C:\Users\%%i\%curUserStartMenu%" mkdir "C:\Users\%%i\%curUserStartMenu%" if not exist "C:\Users\%%i\%curUserStartFolder%" mkdir "C:\Users\%%i\%curUserStartFolder%" echo. copy %%i shortcuts... call :func copyDir.bat "User Start Menu Shortcuts-%%i" "%shortcuts%" "C:\Users\%%i\%curUserStartFolder%" Mir ) ) endlocal echo. Done Organizing Start Menu! EXIT /B :func rem Function to call external shared functions call :funcHead "Calling %~1 and waiting" set params="%~2" "%~3" "%~4" "%~5" "%~6" "%~7" "%~8" "%~9" rem echo CALL %includes%\%~1 %params% ::Uncomment to enable debugging echo of all passed parameters CALL %includes%\%~1 %params% EXIT /B :dots REM just echoing dots in a Function instead of copy pasting them so that it's consistent echo ...................................................................... EXIT /B :funcHead REM A simple function for displaying a consistent header at the start of functions call :dots echo. %~1 call :dots rem @pause ::Uncomment to enable debugging mode for script EXIT /B
mntShare
::----------------------------------------------------------------------------- :: Arrowhead Dental Lab admin_scripts :: Script Name: mntShare :: Original Author: jfullmer :: Created Date: 2016-06-24 13:34:10 :: Last Updated Date: 2016-07-11 10:12:29 :: Update Author: jfullmer :: Version: 2.9 ::----------------------------------------------------------------------------- @ECHO OFF rem set passed param of the share path to mount as mntPnt set mntPnt=%1 rem To use Persist you have to use a drive letter. Start with A and B set name=%2 call :main rem GOTO :EOF GOTO :EOF :main rem function to mount a share passed as param call :funcHead "Mounting network share" call :setVars echo. "Mounting %mntPnt%..." echo. Deleting any existing shares on %name%... call :func delShare.bat %name:"=%: echo. attempting domain login... call :mnt %login1% %pwFile1% %key1% echo. Checking if domain login mounted successfully... FOR /F "usebackq" %%i IN (`findstr /N /C:"%name%" C:\mnt.txt`) DO SET found=%%i if NOT defined found ( echo. %mntPnt% was not mounted, attempting to mount with local admin login.... call :mnt %login2% %pwFile2% %key2% echo. Checking if drive was mounted... FOR /F "usebackq" %%i IN (`findstr /N /C:"%name%" C:\mnt.txt`) DO SET found2=%%i if NOT defined found2 ( echo. Error echo. Drive could not be mounted, check share path... echo. If error message says multiple users/connections, ignore this ) ) echo. Drive Mounted successfully! echo. Deleting mnt.txt file used to check mounting del C:\mnt.txt EXIT /B :setVars rem Set vars to the domain and local share login names and key paths rem Path to encrypted password and key files set pth=C:\Program Files (x86)\Fog\Keys set includes=\\arrowfs3\scripts\Shared-Functions rem Domain Login set domain1=Arrowhead set user1=Scriptmin set login1=%domain1%\%user1% set pwFile1="%pth%\~" set key1="%pth%\~.key" rem Secondary local admin login set login2=AdlAdmin set pwFile2="%pth%\~2" set key2="%pth%\~2.key" rem variables to call the Powershell command cleaner set psc=Powershell.exe -C set PSDrive=New-PSDrive -Name '%name%' -PSProvider FileSystem -Persist -Root set createCred=-Credential (New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList EXIT /B :mnt rem function to call the New-PSDrive command with encrypted credentials call :funcHead "Mounting drive to %name% with encrypted credentials..." %psc% "%PSDrive% '%mntPnt%' %createCred% '%~1', (Get-Content '%~2' | ConvertTo-SecureString -Key (Get-Content '%~3')));" net use > C:\mnt.txt EXIT /B :func rem Function to call external shared functions call :funcHead "Calling %~1 and waiting" set includes=\\arrowfs3\scripts\Shared-Functions set params="%~2" "%~3" "%~4" "%~5" "%~6" "%~7" "%~8" "%~9" rem echo CALL %includes%\%~1 %params% ::Uncomment to enable debugging echo of all passed parameters CALL %includes%\%~1 %params% EXIT /B :dots REM just echoing dots in a Function instead of copy pasting them so that it's consistent echo ...................................................................... EXIT /B :funcHead REM A simple function for displaying a consistent header at the start of functions call :dots echo. %~1 call :dots rem @pause ::Uncomment to enable debugging mode for script EXIT /B
delShare
::----------------------------------------------------------------------------- :: Arrowhead Dental Lab admin_scripts :: Script Name: delShare :: Original Author: jfullmer :: Created Date: 2016-06-24 14:31:09 :: Last Updated Date: 2016-07-07 10:19:32 :: Update Author: jfullmer :: Version: 1.9 ::----------------------------------------------------------------------------- @ECHO OFF rem Tried looping through param count, but could only echo the string of %1 etc and it didn't parse it as an arg within the for loop. call :funcHead "Deleting Share" echo. Deleting %1 share.... net use %1 /delete /Y >nul GOTO :EOF :dots REM just echoing dots in a Function instead of copy pasting them so that it's consistent echo ...................................................................... EXIT /B :funcHead REM A simple function for displaying a consistent header at the start of functions call :dots echo. %~1 call :dots rem @pause ::Uncomment to enable debugging mode for script EXIT /B
Hopefully someone can help me figure out what I’m doing that the fog service doesn’t like.
-
I don’t think it’s, entirely, the Client having an issue. In nearly all cases the error code returned is coming from the installing program (regardless of if it is a script or not).
-
Check that your share has access for “everyone”, and “anonymous users” ? I didn’t go through all the scripts in detail, I can later though.
-
I am trying using the mapped letters from when I mount the shares.
I also just discovered how to run a command prompt as the system user via psexec (http://stackoverflow.com/questions/77528/how-do-you-run-cmd-exe-under-the-local-system-account)
So I’m using that method to test whether or not it should work via the fog service.
-
@JJ-Fullmer I think I found my problem. I am trying to use a script to mount the shares that is on a share that the system account doesn’t have access to. It works without the fog client because the local admin account has access to it. So I’m a dummy.
So I guess I just either have to always use snapin packs for this method to work, include my mntshare function in every script, or store that script locally on all computers.
-
Added the guest access=Yes option to the share that contains the shared scripts and I think that solved the issue.
Trouble is I don’t really want to allow guest access on that share. I just want to be able to add the system user. But that would require knowing a password for the system user to sync with the linux server (as far as I understand anyway). So that’s cool too. -
My solution was to change where my shared functions were stored/accessed. I just made a extra public share called includes that pointed to that Shared-Functions folder. Now the system account and any account should be able to access them. Which should be fine since they’re all just basic function scripts without any sensitive information in them.
-
@JJ-Fullmer said in Troubleshooting snapins not deploying. Error code 255:
So I guess I just either have to always use snapin packs for this method to work
That’d be my suggestion. Away with shares.
-
@Wayne-Workman But sharing is caring. And it’s so much easier to maintain just one file in a shared location.