VBS script for Win XP 64-Bit cannot run on Windows 7 64-Bit
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, and runs the batch file instead. Seems to run this bit instead on logon: 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
March 2nd, 2011 1:48pm

Hi, That seem the script didn’t compatible with Windows 7. Please try to run it with XP compatible Mode. Furthermore, I suggest to contact VBS Forum to check if the script has problem: http://social.msdn.microsoft.com/Forums/en-us/category/visualbasic The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us. Thank you for your understanding. Regards, Leo HuangPlease remember to click Mark as Answer on the post that helps you, and to click Unmark as Answer if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
Free Windows Admin Tool Kit Click here and download it now
March 4th, 2011 8:33am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics