Solved

file run on specific hard disk

Posted on 2008-10-01
17
407 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
Industry Leaders: 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 500 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 500 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 500 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 500 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Script to copy or move mouse-selected collection of files plus targets referenced by shortcuts (.lnk) The purpose of this article is to help illuminate the real challenges and options available (where they may exist) for utilizing simple scriptin…
This is an addendum to the following article: Acitve Directory based Outlook Signature (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_24950055.html) The script is fine, and works in normal client-server domains…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

729 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