Hello,

I sure hope someone can pull my head out...

OK, I have a USB device that I want to see if its present or plugged
in. Now, this works fine, using cscript on the client as a VBS:

**********************************************************
Const HKEY_LOCAL_MACHINE = &H80000002

strComputer = "."
strValue = "Device Not Found!"

Set objWMIService = GetObject("winmgmts:\\" & strComputer &
"\root\CIMV2")

Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_PnPEntity
WHERE service = 'HidUsb'",,48)

For Each objItem in colItems
strKeyPath = "SYSTEM\CurrentControlSet\Enum\" & objItem.DeviceID
Next

if len(strKeyPath) > 1 then

Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &
strComputer & "\root\default:StdRegProv")
strEntryName = "LocationInformation"
objReg.GetExpandedStringValue HKEY_LOCAL_MACHINE, strKeyPath,
strEntryName, strValue

end if

Wscript.Echo strValue
**********************************************************

When the device is attached objItem.DeviceID returns a portion of the
registry KEY, and I get the value from the registry
LocationInformation. When unplugged I get Device Not Found!

Wonderful, works great.

Problem...

How would I do this using ASP and client side scripting? IIS6.0 would
be the host of the ASP, clients are Windows XP Pro.

Nothing fancy, just a response.write to the clients browser with whats
contained in strValue.

Thanks

ninefofo

Re: Bonkers by Slim

Slim
Fri Apr 07 05:35:36 CDT 2006

who's USB are you detecting, the servers or the clients?

if the server
response.write strValue

if the client

aElement.innerText = strValue

<DIV id=aElement > </DIV>

"ninefofo" <ninefofo@gmail.com> wrote in message
news:1144363870.628879.50260@z34g2000cwc.googlegroups.com...
> Hello,
>
> I sure hope someone can pull my head out...
>
> OK, I have a USB device that I want to see if its present or plugged
> in. Now, this works fine, using cscript on the client as a VBS:
>
> **********************************************************
> Const HKEY_LOCAL_MACHINE = &H80000002
>
> strComputer = "."
> strValue = "Device Not Found!"
>
> Set objWMIService = GetObject("winmgmts:\\" & strComputer &
> "\root\CIMV2")
>
> Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_PnPEntity
> WHERE service = 'HidUsb'",,48)
>
> For Each objItem in colItems
> strKeyPath = "SYSTEM\CurrentControlSet\Enum\" & objItem.DeviceID
> Next
>
> if len(strKeyPath) > 1 then
>
> Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &
> strComputer & "\root\default:StdRegProv")
> strEntryName = "LocationInformation"
> objReg.GetExpandedStringValue HKEY_LOCAL_MACHINE, strKeyPath,
> strEntryName, strValue
>
> end if
>
> Wscript.Echo strValue
> **********************************************************
>
> When the device is attached objItem.DeviceID returns a portion of the
> registry KEY, and I get the value from the registry
> LocationInformation. When unplugged I get Device Not Found!
>
> Wonderful, works great.
>
> Problem...
>
> How would I do this using ASP and client side scripting? IIS6.0 would
> be the host of the ASP, clients are Windows XP Pro.
>
> Nothing fancy, just a response.write to the clients browser with whats
> contained in strValue.
>
> Thanks
>
> ninefofo
>



Re: Bonkers by ninefofo

ninefofo
Fri Apr 07 09:35:28 CDT 2006

OK. The USB device is attached to the client. But I guess I need to
be more explict. Can someone create me an ASP page using my VBScript?
I'm not sure of the client side syntax to wrap my script in.

Thank You.


Re: Bonkers by Slim

Slim
Fri Apr 07 10:06:23 CDT 2006


"ninefofo" <ninefofo@gmail.com> wrote in message
news:1144420528.262559.131710@v46g2000cwv.googlegroups.com...
> OK. The USB device is attached to the client. But I guess I need to
> be more explict. Can someone create me an ASP page using my VBScript?
> I'm not sure of the client side syntax to wrap my script in.
>
> Thank You.
>

you need client side scripting

since your checking the client, you need your script on the client

your script does not need too much changing, but permissions may be a
problem.

the one change I can see at a glace is

Wscript.Echo strValue

need to change to

aElement.innerText = strValue

on you need the html somewhere in your page to display it
<DIV id=aElement > </DIV>



Re: Bonkers by ninefofo

ninefofo
Fri Apr 07 14:58:28 CDT 2006

OK, I stumbled through it. This works as an ASP page.

<HTML>
<TITLE>Find Device</TITLE>

<SCRIPT LANGUAGE="VBScript">

strValue = "Device Not Found!"

Set objWMIService = GetObject("winmgmts:\\.\root\CIMV2")

Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_PnPEntity
WHERE service = 'HidUsb'",,48)

For Each objItem in colItems
strKeyPath = "SYSTEM\CurrentControlSet\Enum\" & objItem.DeviceID
Next

if len(strKeyPath) > 1 then
Set
objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
objReg.GetExpandedStringValue &H80000002, strKeyPath,
"LocationInformation", strValue
end if

Document.Write strValue

Thanks

ninefofo


Re: Bonkers by Slim

Slim
Fri Apr 07 23:58:09 CDT 2006

But your not used the ASP for ASP, you are using it the same as a htm page,
with client script

ASP allows you to script ion the server side, you have not done that, so ASP
is irrelevant to your needs

the page sits on a server
the client downloads the page to his client machine

with asp you can run some script hat can use resources on the server, you
can also run script on the client.

with a htm page you can only run script on the client




"ninefofo" <ninefofo@gmail.com> wrote in message
news:1144439908.556142.94590@j33g2000cwa.googlegroups.com...
> OK, I stumbled through it. This works as an ASP page.
>
> <HTML>
> <TITLE>Find Device</TITLE>
>
> <SCRIPT LANGUAGE="VBScript">
>
> strValue = "Device Not Found!"
>
> Set objWMIService = GetObject("winmgmts:\\.\root\CIMV2")
>
> Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_PnPEntity
> WHERE service = 'HidUsb'",,48)
>
> For Each objItem in colItems
> strKeyPath = "SYSTEM\CurrentControlSet\Enum\" & objItem.DeviceID
> Next
>
> if len(strKeyPath) > 1 then
> Set
> objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
> objReg.GetExpandedStringValue &H80000002, strKeyPath,
> "LocationInformation", strValue
> end if
>
> Document.Write strValue
>
> Thanks
>
> ninefofo
>