Solved

environmet variable

Posted on 2004-03-24
7
182 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
ID: 10668987
set CDROM=d:
0
 

Author Comment

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

Expert Comment

by:JammyPak
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.
0
 
LVL 7

Accepted Solution

by:
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
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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

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…
Ransomware is a malware that is again in the list of security  concerns. Not only for companies, but also for Government security and  even at personal use. IT departments should be aware and have the right  knowledge to how to fight it.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

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