Jump to content

searching for CDROM


WotC

Recommended Posts

thanks! works like a charm. although i have to re-write all of my cmds - and thats quite a lot because i've collected about 120 apps during the last few years... but nevertheless... THANKS

Link to comment
Share on other sites


I have added another loop for the harddrive, just fill in the path that you need.
Dim Act, Drv, Fso, StrDrv
Set Act = CreateObject("Wscript.Shell")
Set Fso = CreateObject("Scripting.FileSystemObject")
Set Drv = Fso.Drives

For Each StrDrv In Drv
If StrDrv.DriveType = 4 Then
If StrDrv.IsReady = True Then
If Fso.FileExists(StrDrv.DriveLetter & ":\win51ip.SP2") Then
'''' PLACE_SCRIPT_HERE_THAT_YOU_NEED_BELOW_HERE
Act.Run("%Comspec% /C @Echo Off && CLS && Mode 55,5 " &_
"&& Color 3f && Echo. && Echo %ComputerName% && set /p = %UserName% Press Key To Close"),1,True
Exit For
End If
End If
End If
Next
'''' CHECK FOR HARDDRIVE BELOW HERE ADD CORRECT PATH FOR FILE EXISTS
For Each StrDrv In Drv
If StrDrv.DriveType = 2 Then
If Fso.FileExists(StrDrv.DriveLetter & ":\win51ip.SP2") Then
'''' PLACE_SCRIPT_HERE_THAT_YOU_NEED_BELOW_HERE
Act.Run("%Comspec% /C @Echo Off && CLS && Mode 55,5 " &_
"&& Color 3f && Echo. && Echo %ComputerName% && set /p = %UserName% Press Key To Close"),1,True
Exit For
End If
End If
Next

In the above you could also check for a folder exists also

EG If Fso.FolderExists(StrDrv.DriveLetter & ":\FOLDER_NAME_HERE") Then

Sorry but i am new into vbs :blushing:

But still dont know where to put all this.

Link to comment
Share on other sites

wherever you want! just call it on purpose using a simple cmd/bat...

but one more question: how do i exit this script? i want the script to close itself whenever it has executed the cmd. so i dont want to run it twice if i have a DVD in my drive AND the folder i'm looking for on my harddisk, too!

If Fso.FolderExists(StrDrv.DriveLetter & ":\Unattended") Then
' PLACE_SCRIPT_THAT_YOU_NEED_BELOW_HERE
Act.Run("Opera.cmd"),1,True
Exit For

I would need an exit from the script right after calling my *.cmd. is WScript.Quit enough?

And - i haven't tried it yet (at least i think so) - when i call the *.vbs and the *.cmd is in the same directory i don't need the full path to the *cmd, do i?

Edited by WotC
Link to comment
Share on other sites

wherever you want! just call it on purpose using a simple cmd/bat...

but one more question: how do i exit this script? i want the script to close itself whenever it has executed the cmd. so i dont want to run it twice if i have a DVD in my drive AND the folder i'm looking for on my harddisk, too!

If Fso.FolderExists(StrDrv.DriveLetter & ":\Unattended") Then
' PLACE_SCRIPT_THAT_YOU_NEED_BELOW_HERE
Act.Run("Opera.cmd"),1,True
Exit For

I would need an exit from the script right after calling my *.cmd. is WScript.Quit enough?

And - i haven't tried it yet (at least i think so) - when i call the *.vbs and the *.cmd is in the same directory i don't need the full path to the *cmd, do i?

1:\ The script exit itself after the cmd file runs Exit For this is the cmd that does it.

2:\ It is alway best to give a full path to the file that you want to run.

Example I ran this script from my desktop which is on D:\Documents and Settings\Gunsmokingman\Desktop

to start this file C:\Testme\TheTest.txt, this needed a full path to the text file for it to run.

Dim Act, Drv, Fso, StrDrv
Set Act = CreateObject("Wscript.Shell")
Set Fso = CreateObject("Scripting.FileSystemObject")
Set Drv = Fso.Drives
For Each StrDrv In Drv
If StrDrv.DriveType = 2 Then
If Fso.FolderExists(StrDrv.DriveLetter & ":\Testme") Then
Act.Run(StrDrv.DriveLetter & ":\Testme\TheTest.txt")
Exit For
End If
End If
Next

Edited by gunsmokingman
Link to comment
Share on other sites

This is an interesting issue as many printer manufacturers now are including multiple card readers in their machines that cause the same problem in ua. Till now I was simply leaving my printer off during install, but is a royal pain in the a** setting up drivers later.

Cheers

MC.

Link to comment
Share on other sites

@qjaclaz:

the second script gives me errors, errors, more errors,... and beside that - its huuuuuge.

the first script checks just for the LAST cdrom. i wasn't interested in finding the last drive, but a particular drive containing a file of my choice. right now i don't see how i could do this using the first script. though maybe i could check all found CDROM drives for the particular file? nevertheless, this still doesn't account for harddrives. but finding the last drive might be useful some day :-)

@gunsmokingman: thanks, i thought the "exit for" just exits - uhm, yes, the "for" loop :-). so i just have to swap the part checking for the cd with the part checking for the hd as my DVD is never as up2date as my hd!

one more offtopic thing: is it very complicated to make a script asking for a userinput (path to My Documents) and closing when there is no input within xxx minutes? right now i'm just checking like this:

IF EXIST "D:\Documents\Default.rdp" SET mydocs="D:\Documents\"
IF EXIST "D:\Documents\Default.rdp" REG ADD "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v "Personal" /t REG_EXPAND_SZ /d "D:\Documents" /f

and so on, inserting the My Music, My Pictures links,...

however, using your script (and your knowledge) i could use a *.vbs checking for a specific folder (that we covered already) instead of the remote desktop settings file OR overwrite a (hopefully) found documents path with a user input (not to forget the timer!) :-)...

soooo - would that be difficult :-) (the timer combined with the userinput?)?

/edit: @qjaclaz:

::find CD-ROM Drive
FOR /F "tokens=3" %%A IN ('ECHO list volume ^| DISKPART.EXE ^| FIND.EXE "-ROM "') DO if exist %%A:\WPI\WPI.ico SET CDROM=%%A:\WPI
FOR /F "tokens=3" %%B IN ('ECHO list volume ^| DISKPART.EXE ^| FIND.EXE "Partition"') DO if exist %%B:\Unattended\WPI\WPI.ico SET CDROM=%%B:\Unattended\WPI
echo Found CD-Rom as drive %cdrom%

Now that is what i call simple and plain! That combined with the "timeout" script... and a possibility to use "do If exist" responding to a folder...

Edited by WotC
Link to comment
Share on other sites

Here is a example of a timed message box, with yes no and a defualt time out.

The first message box that appears has a 60 second timer on it, the three reply

boxes have 15 seconds timers.

Dim Act, Question : Set Act = CreateObject("Wscript.Shell")
Question = Act.Popup ("Would you like to do some thing", 60, "Demo Timed Message Box", 4 + 32)
If Question = 6 Then Act.Popup "User selected yes", 15,"Confirm", 0 + 32 End If
If Question =7 Then Act.Popup "User selected no", 15,"Cancel", 0 + 32 End If
If Question = -1 Then Act.Popup "Time out occur, perform defualt action", 15,"Time Out", 0 + 32 End If

Some Specail folder locations with time message boxes

Const MY_DOCUMENTS = &H5&
Dim Shell : Set Shell = CreateObject("Shell.Application")
Dim MyDoc : Set MyDoc = Shell.Namespace(MY_DOCUMENTS)
Dim MtDocIten : Set MyDocItem = MyDoc.Self
Dim Act : Set Act = CreateObject("Wscript.Shell")
Dim Dtop : Dtop = Act.SpecialFolders("Desktop")
Act.Popup "User Desktop" & vbCrLf & Dtop & vbCrLf & "User Document" & vbCrLf & MyDocItem.Path ,15,"Desktop", 0 + 32

Here is a Link to a list of specail folders

I use VBSedit to write my VBS scripts this is a good program to use here is a Link for VBS Edit

Link to comment
Share on other sites

thanks again! but is it possible to input something (combined with the timer?). if you have another helpful link (like the one to the ms scripting homepage) it would be helpful, too!

Link to comment
Share on other sites

thanks again! but is it possible to input something (combined with the timer?). if you have another helpful link (like the one to the ms scripting homepage) it would be helpful, too!

Do you mean a Inputbox, where you would type in a radom reply, if so no there is no way to do it threw vbs.

There is a work around for it, you would have to use a HTA file that has a textbox and the HTA had a timer on it, that would close after a certin amount of time.

Here is a Example Hta Inputbox save As Timed_Inputbox.Hta

<HEAD><BODY><html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-html40">
<title>User Logon Example</title>
<HTA:APPLICATION APPLICATIONNAME="Owner & Organization" SYSMENU="Yes" MAXIMIZEBUTTON="No"
MINIMIZEBUTTON="No" SCROLL="No" SHOWINTASKBAR="No" SINGLEINSTANCE="yes" Icon="Hta2.ico"/>
<!-- =======================SCRIPT SEPARATOR ======================= -->
<STYLE type="text/css">
/* CLASS BODY CSS */
Body.Normal {font:10.75pt;font-family:Palatino Linotype;color:#004040;filter:progid:DXImageTransform.Microsoft.Gradient
(GradientType=0,StartColorStr='#eeeeee',endColorStr='#5e9ab9');padding-top:1;padding-bottom:1;}
/* THIS CAN BE USED FOR ANT THING THAT NEEDS A CLASS CSS */
.Button {font-family:Palatino Linotype;font-size:10.75pt;font-weight:Bold;line-height:110%;color:#004040;Text-Align:CENTER;filter:
progid:DXImageTransform.Microsoft.Gradient (GradientType=0,StartColorStr='#eeeeee',endColorStr='#64a0bf');width:55;height:25;}
</STYLE></head>
<!-- =======================SCRIPT SEPARATOR ======================= -->
<script language="VBScript">
Dim Act, ComputerName, Fso, IntA, UserName, SD, strInput1, Ts '''' --> VARIBLES FOR THE SCRIPT
'''' --> OBJECTS FOR THE SCRIPT
Set Act = CreateObject("WScript.Shell") : Set Fso = CreateObject("Scripting.FileSystemObject")
'''' --> VARIBLES AS OBJECTS FOR THE SCRIPT
SD = Act.ExpandEnvironmentStrings("%SystemDrive%") : UserName = Act.ExpandEnvironmentStrings("%UserName%")
ComputerName = Act.ExpandEnvironmentStrings("%ComputerName%")
'''' --> START THE TIMER AT 2 MINUTES
IntA = 120
'''' ****************************************************************************************************
*******
'''' --> BODY ON LOAD EVENT
Function bodyLoaded()
window.ResizeTo 437,182 : TextBox0.focus() : Sleep1 : Text1.InnerHtml = ComputerName
Counter.InnerHtml = "Time Left" & Chr(160) & Chr(187) & Chr(160) & InTa & Chr(160) & "Seconds"
Act.Run(SD & "\Rest1.Vbs"),0,true
Do
IntA = IntA - 1
Counter.InnerHtml = "Time Left" & Chr(160) & Chr(187) & Chr(160) & InTa & Chr(160) & "Seconds"
Act.Run(SD & "\Rest1.Vbs"),0,true : Counter.InnerHtml = ""
Loop Until IntA = 0
TimeOut()
End Function
Function TimeOut()
InTa = 0
Do
IntA = IntA + 1
Counter.InnerHtml = "The defualt time out period has expired." : Act.Run(SD & "\Rest1.Vbs"),0,true
Loop Until IntA = 3
Call ExitHta()
End Function
'''' ****************************************************************************************************
*******
'''' --> ENTER BUTTON REPLY
Function Text_Box_Reply()
strInput1 = TextBox0.Value
If strInput1 = "" Then
window.alert "You need to fill in a Valid User Name " & Chr(160) & Chr(171)
document.getElementByID("textbox0").select : CheckTheName()
End If
If strInput1 <> "" Then
CheckTheName()
End If
End Function
'''' ****************************************************************************************************
*******
'''' --> CHECK THAT IT A CORRECT USER NAME THAT LOGON TO THE DESKTOP
Function CheckTheName()
If strInput1 = UserName = True Then
window.alert "Confirm, This was the logon User Name" : ExitHta()
End If
If strInput1 = UserName = False Then
window.alert "This was not the logon User Name"
End If
End Function
'''' ****************************************************************************************************
*******
'''' --> Timer For The Script HTA Does Not Support Wscript.Sleep Function
Function Sleep1
Set Ts = Fso.CreateTextFile(SD & "\Rest1.Vbs", 2, True)
Ts.WriteLine "Wscript.sleep 1000" : Ts.close
End Function
'''' ****************************************************************************************************
*******
'''' --> DELETES THE FILES AND FOLDER IF TRUE
Function ExitHta()
Act.Run("%Comspec% /c Taskkill.exe /f /im Wscript.exe" ),0,True
If Fso.FileExists(SD & "\Rest1.Vbs") Then
Fso.DeleteFile(SD & "\Rest1.Vbs") : Fso.DeleteFile(SD & "\Timed_Inputbox.Hta")
Fso.DeleteFile(SD & "\Hta2.ico")
End If
Act.Run("%Comspec% /c Taskkill.exe /f /im Wscript.exe" ),0,True
Act.Run("%Comspec% /c Taskkill.exe /f /im Mshta.exe"),0,True
Window.Close
End Function
</script>
<center><body onLoad="bodyLoaded()" CLASS="Normal" Scroll="No">
<!-- =======================SCRIPT SEPARATOR ======================= -->
<!-- Logged On User Name --><Table><Td Style="" Width="400">Type In A Valid User Name</Td></Table>
<Table><Td Width="400">
<!-- Enter Button --><input type="button" language="vbscript" Class="Button" Value="Enter" OnClick="Text_Box_Reply">
<!-- Text Box --><input type="text" Size="40" name="textbox0">
<!-- Exit Button --><input type="button" language="vbscript" Class="Button" Value="Close" OnClick="ExitHta">
</Td></Table>
<!-- =======================SCRIPT SEPARATOR ======================= -->
<!-- Counter Text --><Table><Span ID="Counter" STYLE="color:White;font-weight:Bold-Italic;"> </Span></Table>
<!-- Text1 Text --><Table><Span ID="Text1" STYLE="color:#000682;font-weight:Bold-Italic;"> </Span></Table>
<!-- =======================SCRIPT SEPARATOR ======================= -->
</Center></table></body>

Here is a SFX of the above file

Edited by gunsmokingman
Link to comment
Share on other sites

uff - quite a lot of code. this will take some time to dig through it! thanks for the 1000th time. but still one more question (there is always at least one question left :-)). how did you compile the hta to an exe?

Link to comment
Share on other sites

  • 3 weeks later...

Ive been seeking the answer to the same question and I think I have found it!

in a batch file (possibly only 2000/xp not 98/95) the variable %0 is the full path of the script file aka E:\autorun.bat where E:\ is the cd rom drive

use the modifier ~d to give you the drive letter so %~d0 would be simply E: you can easily build from there

xcopy %~d0\files C:\files

http://www.acmesoffware.com/acme/default.asp

Good luck!

Link to comment
Share on other sites

  • 2 months later...

@ WotC

CD-ROMs, Virtual drives, and card readers are assigned subsequent letters following harddisk drives.

So you need a script that stops when it finds your specific drive and doesn't continue searching for more drives.

This will, ACTUALLY, happen before the script reaches your card reader.

This is a script I use @ T-13 to establish a CDROM variable. It searches for a file named "AllAppUA.cmd".

Just make sure you put the correct CD in the drive.

@echo off
if not exist C:\AllAppUA.cmd goto driveD
set CDROM=C:
goto Found
:driveD
if not exist D:\AllAppUA.cmd goto driveE
set CDROM=D:
goto Found
:driveE
if not exist E:\AllAppUA.cmd goto driveF
set CDROM=E:
goto Found
:driveF
if not exist F:\AllAppUA.cmd goto driveG
set CDROM=F:
goto Found
:driveG
if not exist G:\AllAppUA.cmd goto driveH
set CDROM=G:
goto Found
:driveH
if not exist H:\AllAppUA.cmd goto driveI
set CDROM=H:
goto Found
:driveI
if not exist I:\AllAppUA.cmd goto driveJ
set CDROM=I:
goto Found
:driveJ
if not exist J:\AllAppUA.cmd goto driveK
set CDROM=J:
goto Found
:driveK
if not exist K:\AllAppUA.cmd goto driveL
set CDROM=K:
goto Found
:driveL
if not exist L:\AllAppUA.cmd goto driveM
set CDROM=L:
goto Found
:driveM
if not exist M:\AllAppUA.cmd goto driveN
set CDROM=M:
goto Found
:driveN
if not exist N:\AllAppUA.cmd goto driveO
set CDROM=N:
goto Found
:driveO
if not exist O:\AllAppUA.cmd goto driveP
set CDROM=O:
goto Found
:driveP
if not exist P:\AllAppUA.cmd goto driveQ
set CDROM=P:
goto Found
:driveQ
if not exist Q:\AllAppUA.cmd goto driveR
set CDROM=Q:
goto Found
:driveR
if not exist R:\AllAppUA.cmd goto driveS
set CDROM=R:
goto Found
:driveS
if not exist S:\AllAppUA.cmd goto driveT
set CDROM=S:
goto Found
:driveT
if not exist T:\AllAppUA.cmd goto driveU
set CDROM=T:
goto Found
:driveU
if not exist U:\AllAppUA.cmd goto driveV
set CDROM=U:
goto Found
:driveV
if not exist V:\AllAppUA.cmd goto driveW
set CDROM=V:
goto Found
:driveW
if not exist W:\AllAppUA.cmd goto driveX
set CDROM=W:
goto Found
:driveX
if not exist X:\AllAppUA.cmd goto driveY
set CDROM=X:
goto Found
:driveY
if not exist Y:\AllAppUA.cmd goto driveZ
set CDROM=Y:
goto Found
:driveZ
if not exist Z:\AllAppUA.cmd goto NotFound
set CDROM=Z:
goto Found
:NotFound
ECHO XP_APPS CD wasn't found...
exit
:Found
ECHO The XP_APPS CD was found!

< Here Goes the Commands I Use >

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...