Topic: Offline Windows hostname getter  (Read 430 times)

0 Members and 1 Guest are viewing this topic.

Offline Windows hostname getter
« on: September 07, 2016, 12:48:51 AM »

Mikka

  • Code Baker
  • Chef
  • ***
  • Location: Germany
  • Date Registered: May 2012
  • Posts: 234
Hi,

TeraByte added a neat context menu option to their backup solution, a command that will perform a full backup of a selected partition
with pre-selected parameters (target path etc.).

The new image file will also be named accordingly such as C system.root - 2016-09-07 @1310.TBI, I included the partition label system.root.
To make it a distinct name I'd like to also add the hostname of the Windows system of that partition - if existing.

As in a PE %computername% holds e.g. Win81SE, an approach could be:

  • Check a partition for an offline Windows installation
  • Search for and load offline SYSTEM (huge!) as Registry hive
  • Read out a particular Registry value, cf. here
  • Put the value in a new environment variable HostOScsname
  • Make use of the variable for Image for Windows

Scripting all this in AutoIt should be possible but is time consuming.

Is there a simpler/quicker way to read out the hostname of an offline Windows installation?
« Last Edit: September 07, 2016, 12:49:37 AM by Mikka »

Re: Offline Windows hostname getter
« Reply #1 on: September 07, 2016, 06:33:07 AM »

JFX

  • Code Baker
  • Sr. Chef
  • ****
  • Date Registered: Dec 2010
  • Posts: 842
That the right way of doing it, there is no other reliable location to read the computer name.
It should not take much longer than a second.

But you can also look in the \Windows\debug\NetSetup.LOG for the name.
However this log is not updated when the computer name get changed by user.

Re: Offline Windows hostname getter
« Reply #2 on: September 12, 2016, 10:21:29 AM »

Mikka

  • Code Baker
  • Chef
  • ***
  • Location: Germany
  • Date Registered: May 2012
  • Posts: 234
Thanks JFX, it's functional now. However, writing the output into an environment variable (SetEnv) didn't work.
I ended up compiling the .au3 to return the resulting string to cmd level and to proceed there.

 

Powered by EzPortal