WotC Posted April 10, 2006 Author Share Posted April 10, 2006 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 More sharing options...
muiz Posted April 11, 2006 Share Posted April 11, 2006 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 NextIn the above you could also check for a folder exists alsoEG If Fso.FolderExists(StrDrv.DriveLetter & ":\FOLDER_NAME_HERE") ThenSorry but i am new into vbs But still dont know where to put all this. Link to comment Share on other sites More sharing options...
WotC Posted April 11, 2006 Author Share Posted April 11, 2006 (edited) 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_HEREAct.Run("Opera.cmd"),1,TrueExit ForI 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 April 11, 2006 by WotC Link to comment Share on other sites More sharing options...
jaclaz Posted April 11, 2006 Share Posted April 11, 2006 Well, actually it can be done from batch too.Two examples from Rob Van der Woude Scripting site:For XP only (uses diskpart):http://www.robvanderwoude.com/files/cdromxp.txtMore generic:http://www.robvanderwoude.com/amb_cdrom.html#CdRom2jaclaz Link to comment Share on other sites More sharing options...
gunsmokingman Posted April 11, 2006 Share Posted April 11, 2006 (edited) 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_HEREAct.Run("Opera.cmd"),1,TrueExit ForI 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\Desktopto 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 April 11, 2006 by gunsmokingman Link to comment Share on other sites More sharing options...
MAVERICKS CHOICE Posted April 11, 2006 Share Posted April 11, 2006 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.CheersMC. Link to comment Share on other sites More sharing options...
WotC Posted April 11, 2006 Author Share Posted April 11, 2006 (edited) @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" /fand 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 DriveFOR /F "tokens=3" %%A IN ('ECHO list volume ^| DISKPART.EXE ^| FIND.EXE "-ROM "') DO if exist %%A:\WPI\WPI.ico SET CDROM=%%A:\WPIFOR /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\WPIecho 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 April 11, 2006 by WotC Link to comment Share on other sites More sharing options...
gunsmokingman Posted April 12, 2006 Share Posted April 12, 2006 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 replyboxes 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 IfSome Specail folder locations with time message boxesConst 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 + 32Here is a Link to a list of specail foldersI 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 More sharing options...
WotC Posted April 13, 2006 Author Share Posted April 13, 2006 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 More sharing options...
gunsmokingman Posted April 14, 2006 Share Posted April 14, 2006 (edited) 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 April 17, 2006 by gunsmokingman Link to comment Share on other sites More sharing options...
WotC Posted April 14, 2006 Author Share Posted April 14, 2006 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 More sharing options...
gunsmokingman Posted April 14, 2006 Share Posted April 14, 2006 I used Winrar to make it a SFX file. Link to comment Share on other sites More sharing options...
conkie Posted May 3, 2006 Share Posted May 3, 2006 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 driveuse the modifier ~d to give you the drive letter so %~d0 would be simply E: you can easily build from therexcopy %~d0\files C:\fileshttp://www.acmesoffware.com/acme/default.aspGood luck! Link to comment Share on other sites More sharing options...
MAVERICKS CHOICE Posted July 15, 2006 Share Posted July 15, 2006 (edited) @ GSMIf I were to use this in Runonceex from the cd etc would the vb be called prior say from cmdlines.txt or from the actual Runonceex.cmd itself?Just not clearCheersMC. Edited July 15, 2006 by MAVERICKS CHOICE Link to comment Share on other sites More sharing options...
mazin Posted July 15, 2006 Share Posted July 15, 2006 @ WotCCD-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 offif not exist C:\AllAppUA.cmd goto driveDset CDROM=C:goto Found:driveDif not exist D:\AllAppUA.cmd goto driveEset CDROM=D:goto Found:driveEif not exist E:\AllAppUA.cmd goto driveFset CDROM=E:goto Found:driveFif not exist F:\AllAppUA.cmd goto driveGset CDROM=F:goto Found:driveGif not exist G:\AllAppUA.cmd goto driveHset CDROM=G:goto Found:driveHif not exist H:\AllAppUA.cmd goto driveIset CDROM=H:goto Found:driveIif not exist I:\AllAppUA.cmd goto driveJset CDROM=I:goto Found:driveJif not exist J:\AllAppUA.cmd goto driveKset CDROM=J:goto Found:driveKif not exist K:\AllAppUA.cmd goto driveLset CDROM=K:goto Found:driveLif not exist L:\AllAppUA.cmd goto driveMset CDROM=L:goto Found:driveMif not exist M:\AllAppUA.cmd goto driveNset CDROM=M:goto Found:driveNif not exist N:\AllAppUA.cmd goto driveOset CDROM=N:goto Found:driveOif not exist O:\AllAppUA.cmd goto drivePset CDROM=O:goto Found:drivePif not exist P:\AllAppUA.cmd goto driveQset CDROM=P:goto Found:driveQif not exist Q:\AllAppUA.cmd goto driveRset CDROM=Q:goto Found:driveRif not exist R:\AllAppUA.cmd goto driveSset CDROM=R:goto Found:driveSif not exist S:\AllAppUA.cmd goto driveTset CDROM=S:goto Found:driveTif not exist T:\AllAppUA.cmd goto driveUset CDROM=T:goto Found:driveUif not exist U:\AllAppUA.cmd goto driveVset CDROM=U:goto Found:driveVif not exist V:\AllAppUA.cmd goto driveWset CDROM=V:goto Found:driveWif not exist W:\AllAppUA.cmd goto driveXset CDROM=W:goto Found:driveXif not exist X:\AllAppUA.cmd goto driveYset CDROM=X:goto Found:driveYif not exist Y:\AllAppUA.cmd goto driveZset CDROM=Y:goto Found:driveZif not exist Z:\AllAppUA.cmd goto NotFoundset CDROM=Z:goto Found:NotFoundECHO XP_APPS CD wasn't found...exit:FoundECHO The XP_APPS CD was found!< Here Goes the Commands I Use > Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now