Skip to content
View in the app

A better way to browse. Learn more.

MSFN

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

%CDROM% command in VBS files?

Featured Replies

Hi I have usiing WPI for a while now and decided to change the way i install my apps by using the %CDROM% command in WPI so now all my apps are In Root>Software

All the EXE and MSI file work just fine from CD but the few apps i have made.vbs file for say the cant find the file heres an example

Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run ("%systemdrive%\Install\applications\Burning\Alc\setup.exe /qn REBOOT=REALLYSUPPRESS")
WScript.Sleep 19000
WshShell.SendKeys "{TAB}"
WScript.Sleep 1000
WshShell.SendKeys "{ENTER}"
WScript.Sleep 10000
WshShell.SendKeys "{ENTER}"
WScript.Quit

Works fine but when i switch to

Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run ("%CDROM%\software\applications\Burning\Alc\setup.exe /qn REBOOT=REALLYSUPPRESS")
WScript.Sleep 19000
WshShell.SendKeys "{TAB}"
WScript.Sleep 1000
WshShell.SendKeys "{ENTER}"
WScript.Sleep 10000
WshShell.SendKeys "{ENTER}"
WScript.Quit

I get erros saying it error on line 2 "cant find file" but all exe and MSI files lauch fine from WPI so what do i add to make them work? thnx for your time :)

Thats because CDROM isnt a native system variable, you need to add the following code to the beginning of your script...

Set FSO = CreateObject("Scripting.FileSystemObject")
Set AllDrives = FSO.Drives

' Check for CDROM
For Each objDrive In fso.Drives
If objDrive.DriveType = "4" And objDrive.IsReady Then
  If fso.FileExists(objDrive & "\WIN51") Then cdrom = objDrive
End If
Next

If Len(CDROM) = 0 Then
  MsgBox "Error: CD-ROM not found!",vbCritical,"Diskeeper"
  WScript.Quit
End if

NOTE: The above example assumes you have a file called 'WIN51" in the root of your cd.

%cdrom% isn't a system variable, it doesn't exist until a value is set to it

@durex: Although your VBS file works, it has some errors. For example, it sets the AllDrives variable, but never uses it. Also, the message box has the title "Diskeeper" (which makes me believe you didn't write this yourself :)). Here's the right one (I also changed some things to make it a little shorter):

Set FSO = CreateObject("Scripting.FileSystemObject")

For Each Drive In FSO.Drives
  If Drive.DriveType = 4 And Drive.IsReady And FSO.FileExists(Drive & "\WIN51") Then CDROM = Drive
Next

If Len(CDROM) = 0 Then
  MsgBox "Error: CD-ROM not found!", vbCritical
  WScript.Quit
End If

Also, you can't use the variable as %CDROM% like you can in a batch file, but you'll have to use it like this:

WshShell.Run(CDROM & "\Software\Applications\Burning\Alc\setup.exe /qn REBOOT=REALLYSUPPRESS")

@Tsunami

Actually.. theyre not errors, its a cut and paste from a script which I was too lazy to edit... the variable is used later in my script and this was for a Diskeeper install, hence the msgbox title, as I customize my scripts for each program I write them for.... regardless, with or without these couple things it works.

thx for the cleaned up For Next statement

This Will Get The First CD Drive Letter.

Dim strDriveLetter
Dim intDriveLetter
Dim fs 'As Scripting.FileSystemObject
Const CDROM = 4
On Error Resume Next
Set fs = CreateObject("Scripting.FileSystemObject")
strDriveLetter = ""
For intDriveLetter = Asc("A") To Asc("Z")
Err.Clear
If fs.GetDrive(Chr(intDriveLetter)).DriveType = CDROM Then
If Err.Number = 0 Then
strDriveLetter = Chr(intDriveLetter)
Exit For
End If
End If
Next
L=MsgBox ("Your Cd Is: " & strDriveLetter,vbokonly+48,"The Cd Is: " & strDriveLetter )
wscript.quit

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.