BAT file to retrieve Registry Setting

  • Thread starter Thread starter Bart Perrier
  • Start date Start date
B

Bart Perrier

Can anyone help me with a BAT file to pull a String Value from HKLM\Software
and the computer name? I need to send a number of folks out to workstations
that are 95 machines. Rather than try to setup vbScript on each workstation,
I need to use a BAT file.

Thanks,
Bart Perrier
 
In said:
Can anyone help me with a BAT file to pull a String Value from
HKLM\Software and the computer name? I need to send a number of
folks out to workstations that are 95 machines. Rather than try
to setup vbScript on each workstation, I need to use a BAT file.

Does "that are 95 machines" mean they are Windows 95 OS? Or more
probably 95 machines running ???

What string value? Do you have the MS utility REG.EXE?

%COMPUTERNAME% may be sufficient for the computer name.
REG.EXE QUERY args
with subsequent FINDSTR filter, etc. ... Perhaps.

Also, if the systems are in a Domain you may be able to accomplish
the tasks remotely. Possibly utilizing PSEXEC.EXE (Sysinternals).
If not, then is the output to STDOUT, local file, network file? Will
the technicians be logged on locally (or a Domain) Administrators
account? A few more details will help.
 
Thanks for the reply Mark.

The key is HKLM\Software\Citrix\ICA Client\ --> ClientName and the
workstations are the infamous Windows 95 with a few Windows 98s.

I am not sure if these machines have reg.exe on them. If it is not a default
in Win 95, then probably not. I understand that BAT scripting is
considerably different than vbScripting, but is there a way to explicitly
say, "Give me the value at HKLM\Software\Citrix\ICA Client\ --> ClientName"?

I plan to setup a BAT file accessible on the network for each person to run
and then format the output in the COMMAND window with a PAUSE at the end so
they can write it down.

COMPUTERNAME - Computer1
CITRIX CLIENT NAME - CitrixClientName1

Ultimately, I would like to handle a likely NULL value or document what it
will look like. I plan to do this with a, hopefully simple, IF EXIST.

Thanks again Mark.

Bart Perrier
 
Bart said:
Can anyone help me with a BAT file to pull a String Value from
HKLM\Software and the computer name? I need to send a number of
folks out to workstations that are 95 machines. Rather than try
to setup vbScript on each workstation, I need to use a BAT file.
Hi,

If those Win95 computers have Internet Explorer 5.x installed, you
should have no problem using a VBScript for this.
 
[ ]
Thanks for the reply Mark.

The key is HKLM\Software\Citrix\ICA Client\ --> ClientName and
the workstations are the infamous Windows 95 with a few Windows
98s.

I am not sure if these machines have reg.exe on them. If it is
not a default in Win 95, then probably not. I understand that
BAT scripting is considerably different than vbScripting, but is
there a way to explicitly say, "Give me the value at
HKLM\Software\Citrix\ICA Client\ --> ClientName"?

I plan to setup a BAT file accessible on the network for each
person to run and then format the output in the COMMAND window
with a PAUSE at the end so they can write it down.

COMPUTERNAME - Computer1
CITRIX CLIENT NAME - CitrixClientName1

There is no system provided %COMPUTERNAME% in W95, so that is out.
Citrix "name" used to be (long time) stored in WFCNAME.INI, but I
suppose it is now a registry entry.
Ultimately, I would like to handle a likely NULL value or
document what it will look like. I plan to do this with a,
hopefully simple, IF EXIST.
[ ]

Okay. It's been a long time since I've used Windows 95 (really
long <G>), but I can give you some ideas perhaps, even though this
group deals primarily with CMD.EXE on NTx systems.

Use regedit.exe to Export the Keys in question. If you are dealing
with string (REG_SZ) data this should not be too bad.
regedit.exe /x /a "<Drive:>\Directoy\FileName.reg" "KeyPath"
(You will need to confirm those switches exist in W95)

The other registry paths you probably want (confirm it) are:
(watch linewrap)
HKEY_LOCAL_MACHINE\System\CurrentControlSet\control\ComputerName
\ComputerName
"Computername"=
and possibly
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\VxD\VNETSUP
"Computername"=

With command.com's limited facility for parsing, I'm not certain
what you can do other than filtering out the correct line using
FIND. Then perhaps redirect output to a file?

Hope that helps some.
 
Thanks for the help Mark and Torgeir.

I am going to confirm the vbScript capabilities with IE 5.x; all of the 9x
machines should have 5.5 on them. Plus, I will test the WINMGMTS connection.
A few years ago, I ruled out vbScripting with 9x because, if I remember
correctly, it required an install and I was primarily trying to run login
scripts via an NT4 Domain. Even with the install, it did not run the vb
Login Scripts on 9x.

We do not use the Computer Name for the Citrix Name on the majority of our
computers; at least the primary application that we run. Therefore, we
essentially force the Citrix Client to use to use the Reg Key to define the
name. For 2k and better OSes, I can scriptomatically retreive the
information remotely with an already familiar command (StdRegProv).

Again, thanks for your help. I think the desktop folks and their helpers
will have to do it the old fashioned way (Start -> Run -> Regedit...).

Thanks,
Bart "Let me write a script for that" Perrier

Mark V said:
[ ]
Thanks for the reply Mark.

The key is HKLM\Software\Citrix\ICA Client\ --> ClientName and
the workstations are the infamous Windows 95 with a few Windows
98s.

I am not sure if these machines have reg.exe on them. If it is
not a default in Win 95, then probably not. I understand that
BAT scripting is considerably different than vbScripting, but is
there a way to explicitly say, "Give me the value at
HKLM\Software\Citrix\ICA Client\ --> ClientName"?

I plan to setup a BAT file accessible on the network for each
person to run and then format the output in the COMMAND window
with a PAUSE at the end so they can write it down.

COMPUTERNAME - Computer1
CITRIX CLIENT NAME - CitrixClientName1

There is no system provided %COMPUTERNAME% in W95, so that is out.
Citrix "name" used to be (long time) stored in WFCNAME.INI, but I
suppose it is now a registry entry.
Ultimately, I would like to handle a likely NULL value or
document what it will look like. I plan to do this with a,
hopefully simple, IF EXIST.
[ ]

Okay. It's been a long time since I've used Windows 95 (really
long <G>), but I can give you some ideas perhaps, even though this
group deals primarily with CMD.EXE on NTx systems.

Use regedit.exe to Export the Keys in question. If you are dealing
with string (REG_SZ) data this should not be too bad.
regedit.exe /x /a "<Drive:>\Directoy\FileName.reg" "KeyPath"
(You will need to confirm those switches exist in W95)

The other registry paths you probably want (confirm it) are:
(watch linewrap)
HKEY_LOCAL_MACHINE\System\CurrentControlSet\control\ComputerName
\ComputerName
"Computername"=
and possibly
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\VxD\VNETSUP
"Computername"=

With command.com's limited facility for parsing, I'm not certain
what you can do other than filtering out the correct line using
FIND. Then perhaps redirect output to a file?

Hope that helps some.
 
Bart said:
Thanks for the help Mark and Torgeir.

I am going to confirm the vbScript capabilities with IE 5.x; all of the 9x
machines should have 5.5 on them. Plus, I will test the WINMGMTS connection.
Hi,

You will not be able to use the winmgmts on Win9x computers (unless you have
installed the WMI Core 1.5 package on the computers).


Here is a VBScript you can try on the Win95 computers:

'--------------------8<----------------------

Set oWshNet = CreateObject("WScript.Network")
' get name of local computer
sMachineName = oWshNet.ComputerName

sCitrixClientName = RegRead("HKLM\Software\Citrix\ICA Client\ClientName")

sInfoMessage = "COMPUTERNAME: " & sMachineName & vbCrLf _
& "CITRIX CLIENT NAME: " & sCitrixClientName

MsgBox sInfoMessage, vbSystemModal+vbInformation, "Name check"


Function RegRead(sRegValue)
Set oShell = CreateObject("WScript.Shell")
On Error Resume Next
RegRead = oShell.RegRead(sRegValue)
' If the value does not exist, error is raised
If Err Then
RegRead = ""
Err.clear
End If
' If a value is present but uninitialized the RegRead method
' returns the input value in Win2k.
If VarType(RegRead) < vbArray Then
If RegRead = sRegValue Then
RegRead = ""
End If
End If
On Error Goto 0
End Function

'--------------------8<----------------------
 
in message
....snip
The key is HKLM\Software\Citrix\ICA Client\ --> ClientName and the
workstations are the infamous Windows 95 with a few Windows 98s.
....snip

The following Batch files is tested on a default Windows 95 installation,
it uses no third-party or non standard utilities. There was a dummy
string value loaded in a string key created in a key with the name you supply:
HKLM\Software\Citrix\ICA Client
"Some String Key"="Value of string"

Note the "quotes" around the registry path, these are essential
when a path contains [Space]s.

Lines that don't begin with two spaces have wrapped accidentally
====Begin cut-and-paste (omit this line)
@ECHO OFF
start /wait regedit /s /e %TEMP%.\KEY "HKEY_LOCAL_MACHINE\SOFTWARE\Citrix\ICA Client"
TYPE %TEMP%.\KEY | find "="
DEL %TEMP%.\KEY
ECHO.
CHOICE /c:y /n "Please copy value(s) above and press Y to close window "
CLS

====End cut-and-paste (omit this line)
For Win95/98/ME study/demo use. Cut-and-paste as plain-text Batch file.
Batch file troubleshooting: http://www.allenware.com/find?UsualSuspects

Screen capture shows operation:

============Screen capture Windows 95
C:\WORK>demo.bat
"Some String Key"="Value of string"

Please copy value(s) above and press Y to close window
============End screen capture

Assuming the user double-clicked the Batch file to run it,
they merely press Y to close the window after they've
copied down the result on whatever form you provide.
 
Very, very nice. And I've seen you do that before.

I will test this on my typical 95 machine.

Thanks for your thoroughness, Torgeir.

Bart.
 
Bart Perrier said:
Can anyone help me with a BAT file to pull a String Value from HKLM\Software
and the computer name? I need to send a number of folks out to workstations
that are 95 machines. Rather than try to setup vbScript on each workstation,
I need to use a BAT file.
Hi Bart,

the Win95 batch language is poor. Because of this there exist a
huge bunch of batch enhancers.

Years ago I preferred Kixtart (see http://www.kixtart.org )
This tiny script was designed for logon scripting.
It specialty is registry editing and ini file editing.

You find literally 1000s of examples in
http://www.kixtart.org/ubbthreads/ubbthreads.php?Cat=


Did you already try the use of remote registry?
Try the following from your WinXP box:

reg query \\win95box\HKLM\Software

IIRC the HKLM key should be open for reading.


Reinhardt
 
Very nice William. I have played around with it enough to get exactly what I
need. Thanks for the links as well.

However, my heart is for VBScript so I am going to push that direction with
this BAT file as a contingency.

Thanks again,
Bart Perrier


William Allen said:
in message
...snip
The key is HKLM\Software\Citrix\ICA Client\ --> ClientName and the
workstations are the infamous Windows 95 with a few Windows 98s.
...snip

The following Batch files is tested on a default Windows 95 installation,
it uses no third-party or non standard utilities. There was a dummy
string value loaded in a string key created in a key with the name you supply:
HKLM\Software\Citrix\ICA Client
"Some String Key"="Value of string"

Note the "quotes" around the registry path, these are essential
when a path contains [Space]s.

Lines that don't begin with two spaces have wrapped accidentally
====Begin cut-and-paste (omit this line)
@ECHO OFF
start /wait regedit /s /e %TEMP%.\KEY
"HKEY_LOCAL_MACHINE\SOFTWARE\Citrix\ICA Client"
 
Kixtart would be a great way to accomplish this as would a number of
applications with client installs. Unfortunately, I will have to work with
what I have and don't want to give anyone a reason to keep these 9x boxes
around; Citrix is the reason we still have them now. 2000 isn't even my
preference anymore (but I can work with it).

Thanks for the reply Reinhardt,
Bart Perrier
 
Back
Top