environmet variable

Posted on 2004-03-24
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?

Question by:Mario_castro
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
  • 2
LVL 16

Expert Comment

ID: 10668987
set CDROM=d:

Author Comment

ID: 10669017
If the cdrom use other letter??????
LVL 16

Expert Comment

ID: 10669324
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.

Accepted Solution

4auHuk earned 50 total points
ID: 10672216
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
Set Drives = Nothing
Set FileSystemObject = Nothing

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

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


Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

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…
In this blog post, we’ll look at how ClickHouse performs in a general analytical workload using the star schema benchmark test.
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

688 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