VBS variable

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
User avatar
PepsiHog
Automation Wizard
Posts: 517
Joined: Wed Apr 08, 2009 4:19 pm
Location: Florida

VBS variable

Post by PepsiHog » Sun Apr 14, 2013 4:54 am

Hello Everyone,

How can I get my var (MyDrive) in my function to work as the drive specification in Line 4. (I'm counting VBStart as a line, like MS)


[code]
VBSTART
Function DoDriveSpace (MyDrive)
Set objWMIService = GetObject("winmgmts:")
Set objLogicalDisk = objWMIService.Get("Win32_LogicalDisk.DeviceID='MyDrive')"
end function
VBEND

let>MyDrive="D:"
VBEval>DoDriveSpace(%MyDrive%),SpaceOnD

[/code]

Thanks,
PepsiHog
Windows 7

PepsiHog. Yep! I drink LOTS of Pepsi (still..in 2024) AND enjoy programming. (That's my little piece of heaven!)

The immensity of the scope of possibilities within Macro Scheduler pushes the user beyond just macros!

armsys
Automation Wizard
Posts: 1108
Joined: Wed Dec 04, 2002 10:28 am
Location: Hong Kong

Post by armsys » Sun Apr 14, 2013 7:22 am

Hi PepsiHog,
Hope the following script helps:
VBStart
Function DriveExist(drive)
dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
DriveExist = "NO"
If fso.DriveExists(drive) Then
DriveExist = "YES"
End If
End Function
VBEnd
Let>IsDrive_Z=NO
VBEval>DriveExist("Z:"),IsDrive_Z

User avatar
PepsiHog
Automation Wizard
Posts: 517
Joined: Wed Apr 08, 2009 4:19 pm
Location: Florida

Post by PepsiHog » Sun Apr 14, 2013 11:06 pm

Thanks for helping armsys.


SOLVED. I kept playing around and figured it out.

[code]
VBSTART
Function DoDriveSpace(mydrive)
Dim Wazoo
wazoo = "Win32_LogicalDisk.DeviceID=" & "'" & mydrive & "'"
Set objWMIService = GetObject("winmgmts:")
Set objLogicalDisk = objWMIService.Get(wazoo)
DoDriveSpace = objLogicalDisk.FreeSpace
end function
VBEND

let>Drive=D:
VBEval>DoDriveSpace("%Drive%"),SpaceOnDrive
mdl>%SpaceOnDrive%
[/code]

Drink Pepsi, Get Fat,
PepsiHog
Windows 7

PepsiHog. Yep! I drink LOTS of Pepsi (still..in 2024) AND enjoy programming. (That's my little piece of heaven!)

The immensity of the scope of possibilities within Macro Scheduler pushes the user beyond just macros!

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts