Solved

file run on specific hard disk

Posted on 2008-10-01
17
387 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
  • 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
ScreenConnect 6.0 Free Trial

Check out the updates in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI that improves session organization and overall user experience. See the enhancements for yourself!

 

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

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Welcome back!  My apologies for taking so long to write part two of this series; it's been a long time coming!  As I promised in Part 1, this article will focus on how to locate those elusive AD properties that you are searching for.  Why is this us…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

821 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