Jump to content
EduGeek EdSec 2026 is Go! 27th Oct in Derby! Join us for a day of EdTech security focused talks, networking, and an evening social ×

djones

Members
  • Posts

    332
  • Joined

  • Last visited

Everything posted by djones

  1. and
  2. Turbo! I didn't fully understand what 'option explicit' did. Without that in (I'm sure I tried it before but hey...!) it worked. I also had to add another 'on error resume' to the removedrives sub routine to ensure that all existing drives were removed. sub RemoveNetworkDrives Dim NetDrives Dim i Set WSHNetwork = WScript.CreateObject("WScript.Network") Set NetDrives = WSHNetwork.EnumNetworkDrives On Error Resume Next If NetDrives.Count <> 0 Then For i = 0 To NetDrives.Count - 1 WSHNetwork.RemoveNetworkDrive NetDrives(i) Next End If end sub Thanks very much for all your help! I'll upload the complete script for future reference when I've tidied it up a bit. Dave.
  3. Yeah, this was a formatting error - it was all supposed to be on separate lines. However, it still hasn't solved the problem - there must be something else I'm missing :-( Thanks for the help so far! Dave.
  4. Yeah, and everything seems to work apart from the drive renaming! The same code works in another script I use so it is very frustrating. Haven't had the chance to continue testing this week though. Dave
  5. I wasn't sure whether subroutines needed the variables defining separately. Can I simply specify them once at the start?
  6. So it has! Editted in EditPad Lite and Notepad depending on which computer I was on at the time. Never noticed any problems before - I've removed the extra characters and tidied the formatting and will try again tomorrow. Thanks, Dave.
  7. Thank you, here it is at present... Dave. login3.txt
  8. Yeah, I thought of that one. No change with the error message AFAIR.
  9. @apeo: Thanks, that did the trick. OK, I've now to sort the renaming bit. The code I'm trying to use works in another (old) logon script but not in this one which gives a weird error message. ' Map Network Drives By User Group IF IsMember("CLASS TEACHERS") THEN MapDrive "J:", "\\server\Curriculum$" MapDrive "G:", "\\server\Staff Share$" MapDrive "R:", "\\server\Pupil Resources$" MapDrive "P:", "\\server\Pupils$" mDrive1 = "G:\" mDrive2 = "J:\" mDrive4 = "P:\" mDrive5 = "R:\" Set oShell = CreateObject("Shell.Application") oShell.NameSpace(mDrive1).Self.Name = "School Organisation" oShell.NameSpace(mDrive2).Self.Name = "Curriculum Planning" oShell.NameSpace(mDrive4).Self.Name = "Pupil Folders" oShell.NameSpace(mDrive5).Self.Name = "Pupil Resources" END IF When I try to run it this way, I get an "expected end statement" (or similar) at line # (mDrive2 = "J:\"), character # (the quote mark before the 'J'). However, this error doesn't seem to marry up with anything. I have tried a few different combinations/placements but I feel like I'm stumbling in the dark and not really getting anywhere! Any suggestions? Dave.
  10. I just had a thought about the 'RenameNetworkDrives' part... Would it work (I can't test at the moment) if the relevant code was included at the end of each 'IF' statement? For example: ' Map Network Drives By User Group IF IsMember("ANCILLARY STAFF") THEN MapDrive "G:", "\\server\Staff Share$" mDrive1 = "G:\" Set oShell = CreateObject("Shell.Application") oShell.NameSpace(mDrive1).Self.Name = "School Organisation" END IF IF IsMember("CLASS TEACHERS") THEN MapDrive "J:", "\\server\Curriculum$" MapDrive "G:", "\\server\Staff Share$" MapDrive "R:", "\\server\Pupil Resources$" MapDrive "P:", "\\server\Pupils$" mDrive1 = "G:\" mDrive2 = "J:\" mDrive4 = "P:\" mDrive5 = "R:\" Set oShell = CreateObject("Shell.Application") oShell.NameSpace(mDrive1).Self.Name = "School Organisation" oShell.NameSpace(mDrive2).Self.Name = "Curriculum Planning" oShell.NameSpace(mDrive4).Self.Name = "Pupil Folders" oShell.NameSpace(mDrive5).Self.Name = "Pupil Resources" END IF Could this then be shortened to: ' Set Environment Variables Set oShell = CreateObject("Shell.Application") ' Map Network Drives By User Group IF IsMember("ANCILLARY STAFF") THEN MapDrive "G:", "\\server\Staff Share$" oShell.NameSpace(G:\).Self.Name = "School Organisation" END IF IF IsMember("CLASS TEACHERS") THEN MapDrive "J:", "\\server\Curriculum$" MapDrive "G:", "\\server\Staff Share$" MapDrive "R:", "\\server\Pupil Resources$" MapDrive "P:", "\\server\Pupils$" oShell.NameSpace(G:\).Self.Name = "School Organisation" oShell.NameSpace(J:\).Self.Name = "Curriculum Planning" oShell.NameSpace(P:\).Self.Name = "Pupil Folders" oShell.NameSpace(R:\).Self.Name = "Pupil Resources" END IF
  11. Please bare with me on this one! I am trying to consolidate a few functions etc into one script for all that assigns printers (according to computer name and hence location), maps drives (according to group membership), etc... I used ScriptBuilder to build the initial script and am now trying to add a few functions from other scripts that I use/have used. However, my scripting skills leave at lot to be desired and I am struggling to get various bits working. Here is what I have so far (minus some repetitive bits): ' Set Environment Variables OPTION EXPLICIT ON ERROR RESUME NEXT DIM WSHNetwork, objFSO DIM ComputerName, UserName SET WSHNetwork = CreateObject("Wscript.Network") SET objFSO = CreateObject("Scripting.FileSystemObject") ComputerName = WSHNetwork.ComputerName UserName = UCASE(WSHNetwork.UserName) ' Clean Up Any Previous Settings RemoveNetworkPrinters RemoveNetworkDrives ' Wait For Disconnect wscript.sleep 300 ' Add Network Printers By Computer Name IF BeginsWith(ComputerName,"AMBER") THEN AddPrinter "\\server\AmberBW", True AddPrinter "\\server\AmberColour", False END IF IF BeginsWith(ComputerName,"CURLAP") THEN AddPrinter "\\server\IoliteBW", False AddPrinter "\\server\JadeBW", False AddPrinter "\\server\AmethystColour", False AddPrinter "\\server\MoonstoneBW", False AddPrinter "\\server\MoonstoneColour", False AddPrinter "\\server\AmberBW", False AddPrinter "\\server\JasperColour", False AddPrinter "\\server\JadeColour", False AddPrinter "\\server\JasperBW", False AddPrinter "\\server\EmeraldColour", False AddPrinter "\\server\AmberColour", False AddPrinter "\\server\ReceptionColour", False AddPrinter "\\server\EmeraldBW", False AddPrinter "\\server\ReceptionBW", False AddPrinter "\\server\IoliteColour", False AddPrinter "\\server\AmethystBW", False END IF ' Removed: Lots of additional printer assignments by rooms/areas ' Map Network Drives By User Group IF IsMember("ANCILLARY STAFF") THEN MapDrive "G:", "\\server\Staff Share$" END IF IF IsMember("CLASS TEACHERS") THEN MapDrive "J:", "\\server\Curriculum$" MapDrive "G:", "\\server\Staff Share$" MapDrive "R:", "\\server\Pupil Resources$" MapDrive "P:", "\\server\Pupils$" END IF IF IsMember("OFFICE STAFF") THEN MapDrive "O:", "\\server\Office Share$" MapDrive "G:", "\\server\Staff Share$" MapDrive "S:", "\\server\Adapps$" END IF IF IsMember("PUPILS") THEN MapDrive "R:", "\\server\Pupil Resources$" MapDrive "P:", "\\server\Pupils$" END IF IF IsMember("SLT") THEN MapDrive "O:", "\\server\Office Share$" MapDrive "J:", "\\server\Curriculum$" MapDrive "P:", "\\server\Pupils$" MapDrive "R:", "\\server\Pupil Resources$" MapDrive "S:", "\\server\Adapps$" MapDrive "G:", "\\server\Staff Share$" END IF IF IsMember("TAS") THEN MapDrive "J:", "\\server\Curriculum$" MapDrive "P:", "\\server\Pupils$" MapDrive "G:", "\\server\Staff Share$" MapDrive "R:", "\\server\Pupil Resources$" END IF ' Add Further Settings RenameNetworkDrives BGInfo StartMenuClick CopyMoveToFolder ' Sub Routine Code sub RemoveNetworkPrinters Dim i Dim objPrinters,WSHNetwork Dim PrinterPath Set WSHNetwork = WScript.CreateObject("WScript.Network") Set objPrinters = WSHNetwork.EnumPrinterConnections for i = 0 to objPrinters.Count - 1 PrinterPath = objPrinters.Item(i) ' * Only remove network printers if mid(PrinterPath, 1, 2) = "\\" then WSHNetwork.RemovePrinterConnection PrinterPath, True, True end if next end sub sub RemoveNetworkDrives Dim NetDrives Dim i Set NetDrives = WSHNetwork.EnumNetworkDrives If NetDrives.Count <> 0 Then For i = 0 To NetDrives.Count - 1 WSHNetwork.RemoveNetworkDrive NetDrives(i) End If end sub sub RenameNetworkDrives mDrive1 = "G:\" mDrive2 = "J:\" mDrive3 = "O:\" mDrive4 = "P:\" mDrive5 = "R:\" mDrive6 = "S:\" Set oShell = CreateObject("Shell.Application") oShell.NameSpace(mDrive1).Self.Name = "School Organisation" oShell.NameSpace(mDrive2).Self.Name = "Curriculum Planning" oShell.NameSpace(mDrive3).Self.Name = "Office" oShell.NameSpace(mDrive4).Self.Name = "Pupil Folders" oShell.NameSpace(mDrive5).Self.Name = "Pupil Resources" oShell.NameSpace(mDrive6).Self.Name = "MIS" end sub sub BGInfo Set objShell = CreateObject("Wscript.Shell") objShell.Run "\\server\NETLOGON\BGInfo\BGInfo.exe \\server\NETLOGON\BGInfo\Default.bgi /nolicprompt /timer:0", 1, True end sub sub StartMenuClick Dim smpath smpath = "HKCU\Control Panel\Desktop\" 'The following line will REQUIRE a click in the start menu WSHShell.RegWrite smpath & "MenuShowDelay","65535","REG_SZ" 'To undo what the above line has done, 'comment out the above line and uncomment the following... 'WSHShell.RegWrite smpath & "MenuShowDelay","400","REG_SZ" end sub sub CopyMoveToFolder Dim ctmtpath ctmtpath = "HKEY_CLASSES_ROOT\AllFilesystemObjects\shellex\ContextMenuHandlers\" WSHShell.RegWrite ctmtpath,"CopyTo" WSHShell.RegWrite ctmtpath & "\CopyTo\","{C2FBB630-2971-11D1-A18C-00C04FD75D13}" WSHShell.RegWrite ctmtpath,"MoveTo" WSHShell.RegWrite ctmtpath & "\MoveTo\","{C2FBB631-2971-11d1-A18C-00C04FD75D13}" end sub ' Built-in Functions Function EndsWith(ByVal str1, ByVal str2) If Len(str2) > Len(str1) Then EndsWith = False Else If Mid(str1, Len(str1) - Len(str2) + 1, Len(str2)) = str2 Then EndsWith = True Else EndsWith = False End If End If End Function Function BeginsWith(ByVal str1, ByVal str2) If Mid(str1, 1, Len(str2)) = str2 Then BeginsWith = True Else BeginsWith = False End If End Function Function IsMember(Byval groupName) DIM domain, blnIsMember DIM objUser, grp domain = WSHNetwork.UserDomain blnIsMember = False SET objUser = GetObject("WinNT://" & domain & "/" & UserName & ",user") For Each grp In objUser.Groups If LCASE(grp.Name) = LCASE(groupName) Then blnIsMember = True Exit For End If Next IsMember = blnIsMember End Function Function MapDrive(Byval Drive, Byval Path) If Not objFSO.DriveExists(Drive) Then WSHNetwork.MapNetworkDrive Drive, Path End If End Function Function AddPrinter(Byval PrintServer, Byval Default) WSHNetwork.AddWindowsPrinterConnection(PrintServer) IF Default THEN WSHNetwork.SetDefaultPrinter PrintServer End If End Function ' Clean Up Variables set WSHNetwork = Nothing Set objFSO = nothing Set objUser = nothing Set objShell = nothing Set oShell = nothing Set clDrives = nothing Set objPrinters = nothing Set smpath = nothing ' Quit the Script wscript.quit Now...printer assignment works and so too does drive mapping. However, neither the 'RemoveNetworkDrives' nor 'RenameNetworkDrives' functions work. A less important couple of bits that also fail are the 'CopyMoveToFolder' and 'StartMenuClick'. I got these snippets from the tech-tips forums and thought they'd be useful additions! I appreciate I'm probably trying to run before I walk but I figure that if you don't try, you don't learn and don't succeed! Can anyone help spot any errors or suggest improvements to make this work? Thanks, Dave.
  12. I'm beginning to experiment with VMWare and have successfully used VMWare Converter to migrate an existing physical machine (a laptop) to a virtual machine (using VMWare Server v1.0.4) on another laptop. However, I don't seem to be able to use the wireless NIC in the virtual machine. Is this possible at all - have I missed something obvious? Dave
  13. Do you use the -reseal -mini switches when running sysprep? This should prevent the issue...according to several articles I've just found on the subject. They are the options I use when sysprep'ing which may explain why I've not seen the problem with deploying my image - but then again it could just be a red herring. Enjoy the cricket!
  14. There is a very convoluted workaround detailed in this article: http://support.microsoft.com/kb/320279 ...but it does appear to be WMP11 that can cause this. Oddly though, I have WMP11 installed on my generic image and this doesn't cause any probems. Are you using the latest version of sysprep too? Dave.
  15. Not completely sure, just remember reading something about an incompatibility between sysprep and WMP11 - registry setting becoming corrupt. I'll have a look through my saved links.
  16. Do you have Windows Media Player v11 installed on the base machine you are creating the image from?
  17. sysprep is available from the Support\Tools folder on a Window XP CD. You will need to extract the contents of the Deploy.cab file (double click) to get all the associated files. The latest (SP2) version can be downloaded if you haven't got an SP2 CD available. With the SP2 version of sysprep, to avoid the Administrator profile being copied over your newly tweaked Default Profile you will need to download and apply hotfix 887816 before running sysprep.exe. Dave.
  18. It really isn't. I thought so too before I actually started playing with it and for years put off using this 'mythical beast' they called 'sysprep'! Instead, I just loaded up one machine type with all software, ghosted and then used NewSID to change the name and security IDs. I then repeated this for any other machine types. This meant that I had to create, store and maintain several different 'images' which was relatively easy and straight forward but time consuming, took up a lot of storage space and was generally a right royal PITA. Once I bit the bullet and finally investigated using sysprep I was pleasantly surprised how easy it was. I did come across a few issues that made my life harder initially but with those two machine types (GX520 & 755) you really shouldn't have any difficulties. The basic steps are: 1. Load one computer with all software etc 2. Download and extract all driver files for both machine types and store on the hard drive (e.g. C:\Drivers) 3. Extract and store sysprep files on hard drive (e.g. c:\sysprep) 4. Create sysprep.inf configuration file (this can be created for you using the sysprepmgr.exe program that was extracted in step 3.) 5. Run sysprep.exe and shutdown. 6. Turn on and ghost. 7. Deploy image. There is an excellent video tutorial on this site (at the bottom) that may be of further help to visualise the steps. Don't be daunted or put off - if you can use ghost, you can use sysprep. It will save time in the long run. Dave.
  19. Yes you can use ghost to do what you want. You would need to use sysprep to prepare one machine before creating the image and in the sysprep.inf config file, specify the hardware and location of necessary drivers etc for both machine types. When you deploy the ghost image to either machine type, mini-setup will run automatically and load the correct drivers for that machine. The nice part of all of this is that you can then have sysprep automatically join the computer to a domain for you plus a few other useful tasks. I use this method (and have both the GX520 and 755 machines plus others) and have put together a guide that may help you: http://www.midteq.co.uk/index.php?option=com_content&task=view&id=47&Itemid=68 There are some sections that may not apply depending on how far you want to go but the most relevant bits to you are probably the sysprep and drivers sections. Dave.
  20. I wasn't sure where to put this question! Can anyone recommend any software (free, if possible, and easy (quick) to use!) for drawing floor/site plans? Dave.
  21. I've been reading up on this with a view to converting my current base image machine (a Dell Latitude D505 laptop) to a VMWare Virtual Machine. I currently use the laptop for altering the generic base image, ghosting (to maintain a clean pre-sysprepped image) then syspreping before capturing with WDS ready for deployment. I want to move to a Virtual Machine so that I can move even further from hardware dependence and enable a faster capture process (using snapshots to remove the pre-sysprep ghost image stage). Am I going to run into problems down the line trying to convert my existing physical machine to a virtual one and then using it for capture/deployment? Would I be better off rebuilding from scratch using VMWare? (I'd rather not have to do that!) Thanks, Dave.
  22. djones

    Startup scripts

    Thanks for all the replies, this is kinda what I have decided is going to be the best option for me in the short term at least. My scripting skills really aren't very hot to say the least and I'm really pushed for time at the moment even getting round to replying here! I think the way I'm going to try and do this is by utilsing a [GuiRunOnce] section in 'sysprep.inf' to call the script that installs the printer drivers (so that restricted user accounts can assign specific printers at login) and then add a call, to another script, in 'CmdLines.txt' to remove/reinstall problem devices (e.g. SCSI/RAID Host Controller). However, I've got a feeling that the execution of 'CmdLines.txt' post mini-setup and before first reboot may be too early for this purpose.
  23. Yes, you would obviously then need to place the 'Drivers' folder under the 'sysprep' folder as you have said. Your 'sysprep.inf' would look something like this: OemPnPDriversPath=Drivers\Dell\745\NIC InstallFilesPath=C:\sysprep ConfirmHardware=No OverwriteOemFilesOnupgrade=No DriverSigningPolicy=Ignore oempreinstall=yes updateInstalledDrivers=Yes *** Note the absence of the 'C:\sysprep\' part in the OEMPnPDriversPath *** However, I tried to do this first too thinking that as the 'sysprep' folder would be automatically deleted, it would tidy things up nicely. Unfortunately, not all my drivers appeared to be installing in time or needed the first reboot to happen completely which, as mini-setup deleted the 'sysprep' folder, caused a few issues. I'm not sure whether this was actually the problem but once I had moved the 'Drivers' folder to the root of the drive and specified 'InstallFilesPath=' as 'C:\' everything seemed to go swimmingly. Dave.
  24. djones

    Startup scripts

    What would be the best way to make a startup script run once as opposed to every time the machine boots? I am using a script (based on fragments from these forums) to load printer drivers (and intend to add: setting default power settings, and add/removing devices) post deployment but this currently runs at every boot. This means that each machine takes longer to get to the logon screen (even longer for laptops when working offline). I'd like the script to only run once following deployment. I know I could disable the appropriate GPO but I'd like a more automated method - maybe as part of the WDS/Sysprep stage. Thanks, Dave.
  25. When you extract the Rxxxxx.exe downloads from Dell, you should end up with a folder containing a series of files and folders as shown in the first attached screenshot. One of these folders will be named WinXP or similar and in there will be the '.cat', '.inf', and '.sys' files as shown in the second screenshot. These are the only files that are usually required for unattended installation. I place these files in a folder such as C:\Drivers\Dell\GX520\NIC and specify the same path in the 'OEMPnPDriversPath' section of my sysprep.inf file so that I end up with: OemPnPDriversPath=Drivers\Dell\755\Chipset;Drivers\Dell\755\Audio;Drivers\Dell\755\Modem;Drivers\Dell\755\Video;Drivers\Dell\755\NIC;Drivers\Dell\D505\Chipset;Drivers\Dell\D505\Audio;Drivers\Dell\D505\Modem;Drivers\Dell\D505\Video;Drivers\Dell\D505\NIC;Drivers\Dell\D510\Chipset;Drivers\Dell\D510\Audio;Drivers\Dell\D510\Modem;Drivers\Dell\D510\Video;Drivers\Dell\D510\NIC;Drivers\Dell\D510\Wireless;Drivers\Dell\D520\Chipset;Drivers\Dell\D520\Audio;Drivers\Dell\D520\Modem;Drivers\Dell\D520\Video;Drivers\Dell\D520\NIC;Drivers\Dell\D520\Wireless;Drivers\Dell\GX520\Chipset;Drivers\Dell\GX520\Audio;Drivers\Dell\GX520\Modem;Drivers\Dell\GX520\Video;[b]Drivers\Dell\GX520\NIC[/b] InstallFilesPath=C:\ ConfirmHardware=No OverwriteOemFilesOnupgrade=No DriverSigningPolicy=Ignore oempreinstall=yes updateInstalledDrivers=Yes Sysprep will not recursively search subfolders so you must copy all required files into the top level folder you have specified in 'OemPnPDriversPath' Dave.
×
×
  • Create New...