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

Problem executing snapin script

Scheduled Pinned Locked Moved Unsolved
Windows Problems
1
2
218
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.
  • T
    tahitiju
    last edited by Dec 18, 2024, 5:07 PM

    Hi,

    I’m looking to deploy a device driver on a Windows 10 machine using a Snapin Pack.

    I’ve created a .zip file containing the necessary files + an install.bat batch script.

    The problem I’m encountering is that the script executes correctly according to FOG (return code 0), but some lines of the script (the most important ones in fact) are simply not executed.

    I’ve extended the script to save the command execution output in a file (c:\tmp\usb-blaster-install.txt) so that I can understand where the problem lies.

    install.bat :

    rmdir /S /Q c:\tmp
    mkdir c:\tmp
    
    echo "start" 1> c:\tmp\usb-blaster-install.txt 2>&1
    echo %cd% 1>> c:\tmp\usb-blaster-install.txt 2>&1 
    
    where pnputil 1>> c:\tmp\usb-blaster-install.txt 2>&1
    pnputil 1>> c:\tmp\usb-blaster-install.txt 2>&1
    C:\Windows\System32\pnputil.exe /add-driver usbblstr.inf /subdirs /install 1>> c:\tmp\usb-blaster-install.txt 2>&1
    
    where python 1>> c:\tmp\usb-blaster-install.txt 2>&1
    python -V 1>> c:\tmp\usb-blaster-install.txt 2>&1
    
    echo "end" 1>> c:\tmp\usb-blaster-install.txt 2>&1
    

    For some reason, lines 7, 8 and 9 containing the pnputil command are not executed.
    The pnputil command is present on the system, and the script runs when I copy it and run it locally, but not via the FOG agent.

    Here’s the content of my output file when I run it via fog, it contains some strange characters :

    "start" 
    C:\Program Files (x86)\FOG\tmp\drivers-usb-blaster  
    Informationÿ: impossible de trouver des fichiers pour le(s) modŠle(s) sp‚cifi‚(s).
    'pnputil' n'est pas reconnu en tant que commande interne
    ou externe, un programme ex‚cutable ou un fichier de commandes.
    'C:\Windows\System32\pnputil.exe' n'est pas reconnu en tant que commande interne
    ou externe, un programme ex‚cutable ou un fichier de commandes.
    C:\ProgramData\anaconda3\python.exe
    Python 3.10.9
    "end" 
    

    As I said above, when I run it locally the script executes well and the output file contains the expected commands, and no weird characters.
    I’m not sure what the problem could be, as if the terminal launched by fog were running with a particular encoding.
    If you have an idea in mind, please let me know.

    Julien

    1 Reply Last reply Reply Quote 0
    • T
      tahitiju
      last edited by Feb 13, 2025, 2:38 PM

      I was unable to resolve this issue with pnputil using a cmd.exe script.

      I noticed that the problem was also present on another FOG installation managed by other system administrators.

      I assume (perhaps wrongly) that the problem is linked to an ANSI/UTF encoding issue. If someone using another language manages to run pnputil.exe in a cmd.exe script, report it here.

      I was finally able to resolve this driver deployment issue using powershell. I’m leaving a sample code (install of a driver named usbblstr.inf) in case it helps someone.

      New-Item -Path "c:\" -Name "drivers" -ItemType "directory" -Force
      Copy-Item -Path "usb-blaster" -Destination "C:\drivers" -Recurse
      Start-Process -FilePath "pnputil.exe" -ArgumentList "/add-driver C:\drivers\usb-blaster\usbblstr.inf /subdirs /install" -RedirectStandardOutput "$env:tmp\usb-blaster-install.txt" -RedirectStandardError "$env:tmp\usb-blaster-err.txt"
      

      Sincerely,

      Julien

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

      193

      Online

      12.0k

      Users

      17.3k

      Topics

      155.2k

      Posts
      Copyright © 2012-2024 FOG Project