?
Solved

file run on specific hard disk

Posted on 2008-10-01
17
Medium Priority
?
410 Views
Last Modified: 2011-10-03
suppose i have my.vbs.now what code i should add so that it will run only on only on selected hard disk . if i changes file to other hard disk then it does not run.
0
Comment
Question by:ankur3020
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 9
  • 8
17 Comments
 
LVL 33

Expert Comment

by:MikeKane
ID: 22615444
VBS will not so this.   Scripts are just a text file.      The script can be copied just like a txt file and moved to a new drive just like a txt file.    Even if you put a test in the script for machine name, ip address, ... whatever...   The file can be opened and edited to allow it to run.  

What you are describing sounds more like DRM (Digital Rights Management)  where a file can only be used on a system after it has been validated.     And that goes beyond the scope of this scripting forum.  
0
 

Author Comment

by:ankur3020
ID: 22615670
where should i put queston then? can u provide code in some other language.
0
 
LVL 33

Expert Comment

by:MikeKane
ID: 22616142
This is basically "how do I setup a DRM distribution"    An admin can weigh in here, but I think this goes way beyond what this site does.  
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:ankur3020
ID: 22616189
can you give me code that read hard disk info.
0
 
LVL 33

Accepted Solution

by:
MikeKane earned 2000 total points
ID: 22616355
What info do you want to read.   VBS offers reading size, name, type, etc...   got this from
http://www.computerperformance.co.uk/vbscript/wmi_disks.htm
 
 
' LogicalDisk.vbs
' Sample VBScript to interrogate a Logical disk with WMI
' Author Guy Thomas http://computerperformance.co.uk/
' Version 1.8 - November 2005
' -------------------------------------------------------------'
Option Explicit
Dim objWMIService, objItem, colItems, strComputer
 
On Error Resume Next
strComputer = "."
 
Set objWMIService = GetObject _
("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery _
("Select * from Win32_LogicalDisk")
 
For Each objItem in colItems
Wscript.Echo "Computer: " & objItem.SystemName & VbCr & _
" ==================================" & VbCr & _
"Drive Letter: " & objItem.Name & vbCr & _
"Description: " & objItem.Description & vbCr & _
"Volume Name: " & objItem.VolumeName & vbCr & _
"Drive Type: " & objItem.DriveType & vbCr & _
"Media Type: " & objItem.MediaType & vbCr & _
"VolumeSerialNumber: " & objItem.VolumeSerialNumber & vbCr & _
"Size: " & Int(objItem.Size /1073741824) & " GB" & vbCr & _
"Free Space: " & Int(objItem.FreeSpace /1073741824) & _
" GB" & vbCr & _
"Quotas Disabled: " & objItem.QuotasDisabled & vbCr & _
"Supports DiskQuotas: " & objItem.SupportsDiskQuotas & vbCr & _
"Supports FileBasedCompression: " & _
objItem.SupportsFileBasedCompression & vbCr & _
"Compressed: " & objItem.Compressed & vbCr & _
""
Next
 
WSCript.Quit
 
' End of Sample DiskDrive VBScript

Open in new window

0
 

Author Comment

by:ankur3020
ID: 22621031
how to write all info the above code generated to a "file".

and what code should i add that compares info on running of above code with saved info in "file" created  last time.
0
 

Author Comment

by:ankur3020
ID: 22621068
code to know hard disk serial number.
0
 
LVL 33

Assisted Solution

by:MikeKane
MikeKane earned 2000 total points
ID: 22624127
Hard drive info can be retrieved using the steps on these examples:
http://addressof.com/blog/archive/2004/02/13/386.aspx



Or with this code in VB

set svc = getobject ("winmgmts:root\cimv2")
set objEnum = svc.execQuery ("select * from win32_physicalMedia")
for each obj in objEnum
wscript.echo obj.GetObjectText_
next

and run this run in command mode (you can shell out to this) for example

cscript sn.vbs >result.txt
0
 

Author Comment

by:ankur3020
ID: 22635456
thanks code is giving info about hard disk but i want to use this info in if statement.pls provide code for that so that i can compare out of above code.
0
 
LVL 33

Assisted Solution

by:MikeKane
MikeKane earned 2000 total points
ID: 22635731
If these are windows systems, you can evaluate an If ont he registry key in WGA
HKLM\Software\Microsoft\Windows Genuine Advantage\HDSLN





On Error Resume Next
Dim objShell
Dim strShell, strMBS
 
strMBS = "HKLM\SOFTWARE\Microsoft\Windows Genuine Advantage\HDSLN"
 
Set objShell = CreateObject("WScript.Shell")
 
strShell = objShell.RegRead(strMBS)
 
If strShell = "XXXXXXXXX" Then
	'Run code
End If 

Open in new window

0
 

Author Comment

by:ankur3020
ID: 22641556
i did not find any such each as you mentioned in above code. pls guide what to do to use output of harddisk volumer no.

0
 
LVL 33

Expert Comment

by:MikeKane
ID: 22649681
Is your Machine a windows with WGA installed?   If so, then the key is there.  

I've provided code to list the Harddrive serial, and code to run an if then against a specific hard drive serial.  

0
 

Author Comment

by:ankur3020
ID: 22651158
no WGA is not installed on my machine. so any alternative way. or i add this key and then use that for working.
0
 
LVL 33

Assisted Solution

by:MikeKane
MikeKane earned 2000 total points
ID: 22662514
If you dont have WGA then just use the previous code to get the HD serial

set svc = getobject ("winmgmts:root\cimv2")
set objEnum = svc.execQuery ("select * from win32_physicalMedia")
for each obj in objEnum
wscript.echo obj.GetObjectText_
next
0
 

Author Comment

by:ankur3020
ID: 22683817
ok , thanks it is working fine.
0
 
LVL 33

Expert Comment

by:MikeKane
ID: 22686477
We worked through the problem, and now he says its working....    I don't think this should be closed without assigning the points.
0
 

Author Closing Comment

by:ankur3020
ID: 31502002
thanks a lot,
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question