Link to home
Start Free TrialLog in
Avatar of TransitionalData
TransitionalDataFlag for United States of America

asked on

VBS Script to read registry data, HTTP GET/POST to intranet site

Hello,
   I've developed Batch scripts to help in processing freshly imaged computers to quicken the time it takes to process them before putting them in service.  Part of our corporate app creates a unique installation key that needs to be tracked per computer.  My current batch script, shown below
   1. Resets permissions on a registry key.
   2. Ensuring time is accuate
   3. outputs computername System Variables to a text file,
   4. Outputs a second system variable, IMGVER, to the text file
   5. reads a value from the registry (the unique key) using REG
   6. Formatting the exported registry info in the text file with Munge (Less than ideal)
   7. emailing the temp file with Blat.

The information that is being emailed all needs to be tracked.  it's being transposed manually at the moment as it's all in a spreadsheet.  An interal web application is being built for this tracking purpose.

I'm hoping someone can help with building a VBS script to help with the data collection and posting to the internal website.  The URL that will be used is as follows http://server/trackcomputer.php?computername=[computername]&imageversion=[imageversion]&clsid=[exported_registry_value]

So essentially I'm looking to replace lines 3-7 with a VB script that will format the URL and open IE and browse to that site.  I know the VBS could post it blindly, but I'd like it to open IE so I can have visual confirmation that the data has hit the server.

Can someone please help?  Thanks in advance.
subinacl.exe /verbose /subkeyreg \\%COMPUTERNAME%\HKEY_LOCAL_MACHINE\Software\PowerEcho /grant=everyone=F
net time /set /y
echo EMS Computer Name: %COMPUTERNAME% > %TEMP%\clsid.txt
echo Image Version Number: %IMGVER% >> %TEMP%\clsid.txt
REG QUERY HKEY_LOCAL_MACHINE\Software\PowerEcho /v CLSID >> %TEMP%\clsid.txt
c:\Windows\script_bin\munge.exe c:\windows\script_bin\replacements.ini -nt %TEMP%\clsid.txt
c:\windows\script_bin\blat.exe %TEMP%\clsid.txt -to sample@emailaddress.com -subject "CLSID For Imaged Laptop"

Open in new window

Avatar of ltlbearand3
ltlbearand3
Flag of United States of America image

I am not familiar with the DOS variable IMGVER and my machine is not showing this.  If you can give me more information I might be able to incorporate that into the script.  Below is a shot at a vb script to do lines 3-7.  I can't really test on my machine so you will need to give me feedback.  Thanks.

Copy and past the code into a text file and save as postinfo.vbs (or whatever you want to call it)

-Bear

Dim objComputer, objRegistry, objExplorer
Dim strComp, strImgVer, strRegComp
Dim strValue, strKeyPath, strValueName
Const HKEY_LOCAL_MACHINE = &H80000002
 
 
' Get Computer Name
Set objComputer = CreateObject("Shell.LocalMachine")
strComp = objComputer.MachineName
 
' Get Image Version
' ***** NOT SURE WHERE YOU ARE GRABING THIS VARIABLE FROM *******
strImgVer = ""
 
' Get Registry Value
strRegComp = "."	' Local Machine
Set objRegistry=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
    strComputer & "\root\default:StdRegProv")
 
'Get String value
strKeyPath = "Software\PowerEcho"
strValueName = "CLSID"
objRegistry.GetStringValue HKEY_CURRENT_USER,strKeyPath,strValueName,strValue
 
' Open IE Window
' For Internet Explorer Message Window
Set objExplorer = WScript.CreateObject("InternetExplorer.Application")
objExplorer.Navigate "http://server/trackcomputer.php?computername=" & strComptuer & "&imageversion=" & strImgVer & "&clsid=" & strValue
   

Open in new window

Avatar of TransitionalData

ASKER

Hi ltlbearand3,
   I should have mentioned that IMGVER is an Environment Variable I've created before syspreping and imaging my machines.  it gives me cmd line access to the revision number of the image.  It is set on all of the Systems that will run the script on.

  I'll give feedback tomorrow when I get an oppertunity to test on one of my systems.  Thanks.
After much delay, I've had time to look again at this script.  The only part that is missing is pulling the Environment Variable I've created "IMGVER" and storing that as a variable to pass along to the server.  I've looked at some VBS documentation and I'm just not proficient in VBS to come up with what is necessary.  can someone help.
ASKER CERTIFIED SOLUTION
Avatar of ltlbearand3
ltlbearand3
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial