It looks like you're using an Ad Blocker.

Please white-list or disable AboveTopSecret.com in your ad-blocking tool.

Thank you.

 

Some features of ATS will be disabled while you continue to use an ad-blocker.

 

Some VBScript help?

page: 1
0

log in

join
share:

posted on May, 17 2007 @ 01:57 AM
link   
I'm busy with a VB .NET (2005) project. I migrated from a desktop application to a APSX. In the desktop application I used to call the Windows Kernel GetVolumeInformation:


Public Declare Function GetVolumeInformation Lib "kernel32"
Alias
"GetVolumeInformationA" (ByVal lpRootPathName As String,
ByVal lpVolumeNameBuffer As String,
ByVal nVolumeNameSize As Integer,
ByRef lpVolumeSerialNumber As Integer,
ByRef lpMaximumComponentLength As Integer,
ByRef lpFileSystemFlags As Integer,
ByVal lpFileSystemNameBuffer As String,
ByVal nFileSystemNameSize As Integer) As Integer


This was used to get the Volume Serial Number of the C drive. Which worked just fine. But if you call this through a web page (an APSX page) you get the Serial Number of the Server on which the page is hosted and NOT the client computer - the one which I'm looking for.

Is there perhaps some VBScript (JScript will also work, but VBScript is preferred...) that either calls the same Windows Kernel, or gets the CLIENT serial number in a different way?

[edit on 17-5-2007 by Gemwolf]



posted on May, 17 2007 @ 07:27 AM
link   
Perhaps something like this:





Public Function GetWMIServices()
Dim strComputer As String
strComputer = "."
GetWMIServices = GetObject("winmgmts:" _
& "[impersonationLevel=impersonate]!\\" & strComputer & "\root\cimv2")
End Function

Public Function ShowHDDInfo() As String
Dim Str As String
Dim objWMIService
Dim colItems
Dim objItem
Dim TheVolume As String
On Error Resume Next
Str = ""
objWMIService = GetWMIServices()
colItems = objWMIService.ExecQuery( _
"Select * from Win32_LogicalDisk")
For Each objItem In colItems
TheVolume = objItem.VolumeSerialNumber
Next
Return TheVolume

End Function

Sub Button2_onclick
Me.Label1.Text = ShowHDDInfo()
End Sub



The problem with the above Script is that it still runs at the Server side, thus returning the Server's serial. The obvious answer would be to remove the "runat=server" tags to get it on the client-side, from both Button 2 and the actual script. But the moment I do that it doesn't see my functions which was declared in the Script... Sigh... Anyone...?

[edit on 17-5-2007 by Gemwolf]



posted on May, 17 2007 @ 11:15 AM
link   
Hmm, maybe this will help.
GetVolumeInformationA conversation


The following is the script of the OCX file :

Public Declare Function GetVolumeSerialNumber Lib "kernel32" Alias "GetVolumeInformationA" (ByVal lpRootPathName As String, ByVal lpVolumeNameBuffer As Long, ByVal nVolumeNameSize As Long, lpVolumeSerialNumber As Long, ByVal lpMaximumComponentLength As Long, ByVal lpFileSystemFlags As Long, ByVal lpFileSystemNameBuffer As Long, ByVal nFileSystemNameSize As Long) As Long

Public Function VolumeSerial(DriveLetter) As Long
Dim Serial As Long
Call GetVolumeSerialNumber(UCase(DriveLetter) & ":\", 0&, 0&, Serial, 0&, 0&, 0&, 0&

VolumeSerial = Serial
End Function


'main code

variablename = VolumeSerial("C")


And in the page of the OCX you must put this code :

<script "VBScript">

document.location.href="http://www.sitename.com/storeit.php?serialnumber=" & nameofcontrol1.serialnumber
</script>


Apparently you need to use an activeX control to do this. I don't know if you can pull this off with just a client side script. That's my initial though on the issue, thus my search narrowed in on that implementation.

[edit on 17-5-2007 by dbates]



posted on May, 18 2007 @ 02:15 AM
link   
Thanks for the help Dbates. I considered using an OCX - I can just use my own code from the original application, and create an OCX from that - but didn't want to because it's always a security issue. You always have to fiddle with your security settings (IExplorer 6 and earlier) to get it installed. So I was hoping to do it with Script. But if I have no other choice, I suppose that's what I'll have to do.

Thanks again for the help!


(Still, if someone knows some miracle client-side script or another solution than an OCX ... It'll be much appreciated!)



posted on Jun, 9 2007 @ 06:13 PM
link   
because vbscript and _javascript are normally server side scripting languages it may not be possible to find certian client information without the use of a pre-installed control to relay the information into a variable. ill keep checking and ask the programmer on my project team at work, the guy is a wiz.



posted on Jun, 10 2007 @ 03:55 PM
link   
Well, I found this.

It uses the Scripting ActiveX to use the FileSystemObject, so it will only works if the Scripting ActiveX is present on the client machine.



posted on Jun, 11 2007 @ 01:02 AM
link   

Originally posted by ArMaP
Well, I found this.

It uses the Scripting ActiveX to use the FileSystemObject, so it will only works if the Scripting ActiveX is present on the client machine.

Thanks ArMaP! That looks like it might just do the job! I'm currently busy with another (very time -consuming) project, when I have a moment I'll give it a try!



new topics

top topics



 
0

log in

join