Solved

file run on specific hard disk

Posted on 2008-10-01
17
370 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
Comment Utility
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
Comment Utility
where should i put queston then? can u provide code in some other language.
0
 
LVL 33

Expert Comment

by:MikeKane
Comment Utility
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
 

Author Comment

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

Accepted Solution

by:
MikeKane earned 500 total points
Comment Utility
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
Comment Utility
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
Comment Utility
code to know hard disk serial number.
0
 
LVL 33

Assisted Solution

by:MikeKane
MikeKane earned 500 total points
Comment Utility
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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 

Author Comment

by:ankur3020
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
ok , thanks it is working fine.
0
 
LVL 33

Expert Comment

by:MikeKane
Comment Utility
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
Comment Utility
thanks a lot,
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Unlike scripting languages such as C# where a semi-colon is used to indicate the end of a command, Microsoft's VBScript language relies on line breaks to determine when a command begins and ends. As you can imagine, this quickly results in messy cod…
This is pretty cool.  The purpose of this VB Script is to help you document where JAR (Java ARchive) files and specifically java class files are located so that you can address issues seen with a client or that you can speak intelligently with a dev…
This video discusses moving either the default database or any database to a new volume.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

743 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now