Jump to content

1cainr

Member
  • Posts

    4
  • Joined

  • Last visited

  • Donations

    0.00 USD 
  • Country

    United Kingdom

Everything posted by 1cainr

  1. Ive got the script working by putting two lines in: Option Explicit '-> Objects For Script Dim Act :Set Act = CreateObject("Wscript.Shell") Dim Net :Set Net = CreateObject("Wscript.Network") '-> Without Using strComputer = "." Dim Wmi :Set Wmi = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2") [color="#FF0000"]dim coldrives[/color] '-> Using strComputer = "." 'Dim strComputer : strComputer = "." 'Dim Wmi :Set Wmi = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _ 'strComputer & "\root\cimv2") '-> Varibles And Check Dim i, Obj, X64 :X64 = False For Each Obj In Wmi.ExecQuery("SELECT * FROM Win32_Processor") If Obj.AddressWidth = 64 Then X64 = True Next '-> Confirm x64 Or x32 OS If X64 = True Then ' WScript.Echo "Confirm X64" Drives() Printer() Else WScript.Echo "Confirm X32" Drives() Printer() End If Function Drives() Set colDrives = Net.EnumNetworkDrives() Those two lines make the script work :-) However when i run the script on a 32-bit OS it brings up the error: The parameter is incorrect for "Set colDrives = Net.EnumNetworkDrives()"
  2. Hello, I only used the batch file because i thought this VBS script wouldnt work on the 32-Bit operating system When i run the script on a 64-Bit OS i get the following error: "Line 34 Char 7 Error Variable is undefined: 'colDrives' Code 800A01F4 Source Microsoft VBScript runtime error " Thank you, Richard
  3. Please see batch file below, i use this on the users which use 32-bit and 64-bit machine. Ill try the vbs script above, thank you :-) ECHO OFF cls ECHO Initialising user environment ... echo Running old script if exist G: net use G: /delete >nul net use G: \\server\cam /persistent:no if exist P: net use P: /delete >nul net use P: \\server\pub /persistent:no if exist S: net use s: /delete >nul net use S: \\server\Share/persistent:no if exist R: net use R: /delete >nul net use R: \\server\radan/persistent:no con2prt /f con2prt /c \\server\print1 con2prt /c \\server\print2 con2prt /c \\server\print3 con2prt /cd \\server\print4
  4. Hello, I created this script for my windows xp 64-bit users and we are now moving them onto windows 7 64 bit. However, when the script runs on logon, it skips the section which its suppose to run and thinks its a 32-bit machine. Seems to run this bit instead: Else ' A batch file is used on a 32-Bit OS Dim wshell set wshell = CreateObject("WScript.Shell") wshell.run "cbc_32Bitversion.bat" set wshell = nothing End if CAN YOU SEE A PROBLEM WITH THE SCRIPT? SEE FULL CODE BELOW: Option Explicit Dim objNetwork,colDrives,i,strComputer, objWMIService, colOperatingSystems, objOperatingSystem, strCaption, colInstalledPrinters, objPrinter, wshShell, strUserName ' Use current machine strComputer = "." Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colOperatingSystems = objWMIService.ExecQuery _ ("Select * from Win32_OperatingSystem") For Each objOperatingSystem in colOperatingSystems strCaption = LCase(objOperatingSystem.Caption) If (InStr(strCaption, "x64") > 0) Then Set objNetwork = CreateObject("Wscript.Network") Set colDrives = objNetwork.EnumNetworkDrives ' Force Removal of network drives and remove from user profile For i = 0 to colDrives.Count-1 Step 2 objNetwork.RemoveNetworkDrive colDrives.Item(i),TRUE,TRUE Next ' Map network drives to user profile objNetwork.MapNetworkDrive "P:", "\\server\public", True objNetwork.MapNetworkDrive "V:", "\\server\J", True objNetwork.MapNetworkDrive "S:", "\\server\E", True objNetwork.MapNetworkDrive "G:", "\\server\ca", True objNetwork.MapNetworkDrive "R:", "\\server\data", True objNetwork.MapNetworkDrive "I:", "\\server\Inv", True ' Find local printers Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") Set colInstalledPrinters = objWMIService.ExecQuery _ ("Select * From Win32_Printer Where Network = True") ' Force Removal of printers from user profile For Each objPrinter in colInstalledPrinters objPrinter.Delete_ Next ' Connect printers to user profile Dim multiPrinter Set multiPrinter = CreateObject("WScript.Network") multiPrinter.AddWindowsPrinterConnection "\\server\eng01-64" multiPrinter.AddWindowsPrinterConnection "\\server\inte01-64" multiPrinter.AddWindowsPrinterConnection "\\server\cad01-64" multiPrinter.AddWindowsPrinterConnection "\\server\cad02-64" multiPrinter.SetDefaultPrinter "\\server\cad02-64" 'Assign users different default printers and mapped drives Set wshShell = WScript.CreateObject( "WScript.Shell" ) strUserName = wshShell.ExpandEnvironmentStrings( "%USERNAME%" ) If strUserName = "mark" or strUserName = "john" Then objNetwork.MapNetworkDrive "T:", "\\server\5000", True End If Else ' A batch file is used on a 32-Bit OS Dim wshell set wshell = CreateObject("WScript.Shell") wshell.run "cbc_32Bitversion.bat" set wshell = nothing End if Next WScript.Quit
×
×
  • Create New...