Current Hardware selection

  • Thread starter Thread starter Larry
  • Start date Start date
L

Larry

Hello,

I have a laptop that I use at four different locations
with each location requiring a different hardware
setting. I know how to create different hardware
profiles (and I have created them), but what I have yet
to figure out is how to tell my different programs which
hardware setting I'm currently using.

Most of my concerns are lan/wan releated. Like the
default printer doesn't get updated, or my system trys to
map to a network drive that's not available at the
current location and so on.

(If only there was a command prompt environment setting
available then I'd have it made, but...)

Any suggestions?

Thank you,

Larry
 
Hi Larry,

Your post intrigued me, so a couple of hours later after playing with
regedit and vbscript I've come up with this

Set WshShell = WScript.CreateObject("WScript.Shell")
ProfileKey =
"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\IDConfigDB\CurrentConfi
g"
ProfileID = WSHShell.RegRead(ProfileKey)
ProfileKey =
"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\IDConfigDB\Hardware
Profiles\000"&ProfileID&"\FriendlyName"
ProfileName = WSHShell.RegRead(ProfileKey)
Set WshEnv = WshShell.Environment("System")
WshEnv("HWProID") = ProfileID
WshEnv("HWProName") = ProfileName

If you copy and paste it into a file with a vbs extension say hwp.vbs or
whatever

Then go into group policy editor and specify it as a system startup script

start/run
gpedit.msc

Computer Configuration/Windows Settings/Scripts(Startup and Shutdown)

Double click startup in the right hand pane and add the path to the script.
Windows XP supports vbs scripts.

This will give you 2 new system environment variables called HWProID and
HWProName

The HWProID is an internal number assigned to each profile, 0 is reserved so
they start at 1.
HWProName is the name you give it in contol panel/system/hardware/hardware
Profiles

I've had to prefill the key with 000 so its good for up to 9 profiles.

It creates these 2 variables as System variables because they need to be non
volatile, otherwise they would disapear when the script stops running. This
is why you need to run the script at startup because rebooting doesnt get
rid of them, and they would be set to their previos values.

Of course if you tack what you want to do into this script they don;t need
to be saved at all.

Best Wishes

Paul
 
Hi Paul,

This is just what the doctor ordered! Although, now, I'm
mad at you. You just opened up a new world to me that
I'm going to have to master. :-)

I never really thought about doing it this way, so I'm
off to learning scripts for this. I'm an old batch file
person, so this kind of thinking will be fun to explore.

Many thanks!

Larry
 
Hey Larry,

I've never written a script either, this took several hours of digging
around on vbscript sites, and using regedit to find where it stored the info
in the registry. I just created a hardware profile called paulshwp, and
searched around for it, after that it was trial and error !

But you're right, you can do an awful lot with scripts.

I'd like know which is the best script language to learn from a system
administration point of view because there do seem several very powerful
ones, vbscript, javascript, windows script host, or is that just an
interpreter, there a program in system32 called cscript which also an
interpreter, where do you start ?
Thats one of the main reasons why, when I looked at scripting a couple of
years ago I ended up not learning any, like you, I stayed with batch files.
Learning something like vbscript is quite a commitment, I want some
reassurance that its THE one to go with!

Paul
 
Back
Top