sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Find computer uuid

    Scheduled Pinned Locked Moved Developers' Forum
    2 Posts 1 Posters 484 Views 1 Watching
    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.
    • JuantxoJ Offline
      Juantxo
      last edited by

      I would like to find motherboard UUID. I almost did, but in Windows SU2014 I must use

      ...force_encoding("utf-16le")...

      I don't know why and the worst, now one SU2014 Windows user is reporting:

      Error: #<ArgumentError: unknown encoding name - utf-16le>

      Someone have an idea about why sometimes not work in Windows, or have a best method to find UUID?

      Code to find UUID:
      MAC OS:
      uuid = %x(ioreg -l | awk '/IOPlatformSerialNumber/ { print }')
      WIN:
      #RUBY_VERSION 1.8
      cmd="wmic csproduct get uuid" uuid = %x(#{cmd})

      #RUBY_VERSION 2.0 (workaround to fix the backquotes bug included):

      cmd="wmic csproduct get uuid" filename = ENV["TMP"].encode("utf-8") + "\\backquote.out" exec_string = "" + cmd + " > " + filename + "" exec_string.gsub! '\\', '/' eval("#{exec_string}") contents = File.read(filename) uuid= contents.force_encoding("utf-16le").encode('UTF-8') uuid.slice!(0)

      1 Reply Last reply Reply Quote 0
      • JuantxoJ Offline
        Juantxo
        last edited by

        Thanks to Driven and Dan.
        I will use new notation instead use force_encoding. I think now it should works...

        #UUID in RUBY 2.0 WINDOWS
        ` cmd="wmic csproduct get uuid"
        filename = File.join(ENV["TMP"],"backquote.out")

        exec_string = "`" + cmd + " > " + filename + "`"
        exec_string.gsub! '\\', '/'
        eval("#{exec_string}")
        
        uuid=""
        open(filename, "r:BOM|utf-16le:UTF-8") do |io|
        	uuid = io.read
        end`
        
        1 Reply Last reply Reply Quote 0
        • 1 / 1
        • First post
          Last post
        Buy SketchPlus
        Buy SUbD
        Buy WrapR
        Buy eBook
        Buy Modelur
        Buy Vertex Tools
        Buy SketchCuisine
        Buy FormFonts

        Advertisement