Solved

environmet variable

Posted on 2004-03-24
7
180 Views
Last Modified: 2010-04-13
hello experts.

i need crate a envrironmet varible that containt the cdrom drive lleter asigned(D: E:), this is because i make a auto instalaer program.

any ideas?

Mario
0
Comment
Question by:Mario_castro
  • 2
7 Comments
 
LVL 16

Expert Comment

by:JammyPak
Comment Utility
set CDROM=d:
0
 

Author Comment

by:Mario_castro
Comment Utility
If the cdrom use other letter??????
0
 
LVL 16

Expert Comment

by:JammyPak
Comment Utility
then use the other letter! (haha)

sorry, I think I misunderstood what you were trying to do - I thought you wanted to set a variable to a known value, not dynamically set it.
0
 
LVL 7

Accepted Solution

by:
4auHuk earned 50 total points
Comment Utility
Hi Mario_castro,
Don't know if you can use VBscript in your case but anyway. Following script will assign CDDRIVE variable first CD-Drive's letter.

'----start setcdvar.vbs----
Set FileSystemObject = CreateObject("Scripting.FileSystemObject")
Set Drives = FileSystemObject.Drives
For Each DiskDrive in Drives
    DriveLetter = DiskDrive.DriveLetter
    If DiskDrive.DriveType = 4 Then
        Set WSHShell = WScript.CreateObject("WScript.Shell")
        WSHShell.Environment.Item("CDDRIVE") = Driveletter & ":\"
        Exit For
    End If
Next
Set Drives = Nothing
Set FileSystemObject = Nothing

'Optional - result output.
WScript.Echo "CDDRIVE = " & WSHShell.Environment.Item("CDDRIVE")

Set WSHShell = Nothing
'----end setcdvar.vbs----

hth,
4auHuk
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

NTFS file system has been developed by Microsoft that is widely used by Windows NT operating system and its advanced versions. It is the mostly used over FAT file system as it provides superior features like reliability, security, storage, efficienc…
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

762 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

10 Experts available now in Live!

Get 1:1 Help Now