Login | |
|
 |
Re: Parsing lines from files and moveing dirs - 6/1/2005 12:16:50 AM
|
|
 |
|
| |
mbouchard
Posts: 1922
Score: 16
Joined: 5/15/2003
From: USA
Status: offline
|
Let me get this straight. You want to parse through data.dat which contains a list of folders, Dira, B, C etc. You then would want to move a folder the folder to a new directory. So, you would want to move C:\DirA and all it's subfolder to D:\DirA.
|
|
| |
|
|
|
 |
Re: Parsing lines from files and moveing dirs - 6/1/2005 2:41:26 AM
|
|
 |
|
| |
Netguard3
Posts: 14
Score: 0
Joined: 5/12/2005
From: Denmark
Status: offline
|
It wont load the correct default printer any ideas ? Option Explicit Const NEW_PRINT_SERVER = "NEWPRINTSERVER" Const HKEY_CURRENT_USER = &H80000001 Dim oReg, WshNetwork, oPrinters Dim strComputer, strKeyPath, strValueName, strValue, strDefault, PrinterPath, strPrinterName Dim intComma, i, intCount, intPrinterLen On Error Resume Next Set WshNetwork = WScript.CreateObject ("WScript.Network") Set oPrinters = WshNetwork.EnumPrinterConnections strComputer = "." strDefault = "" Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" _ & strComputer & "\root\default:StdRegProv") strKeyPath = "Software\Microsoft\Windows NT\CurrentVersion\Windows" strKeyPathXP = "Software\Microsoft\Windows NT\CurrentVersion" strValueName = "Device" strValueNameXP = "Devices" oReg.GetStringValue HKEY_CURRENT_USER,strKeyPath,strValueName,strValue cScript.Echo(strvalue) intComma = InStr(1,strValue,",") cScript.echo(strValue) strDefault = Mid(strValue, 12, intComma - 8) cScript.Echo(strDefault) i = 0 strPrinterName = "" For i = 1 To oPrinters.Count Step 2 intCount = intCount +1 intPrinterLen = Len(oPrinters.Item(i)) MsgBox(intPrinter) strPrinterName = Mid(oPrinters.Item (i), 12, intPrinterLen - 7) WScript.Echo(NEW_PRINT_SERVER & strPrinterName) Err.clear WshNetwork.AddWindowsPrinterConnection NEW_PRINT_SERVER & strPrinterName 'MsgBox "Installed " & strPrinterName If Err Then MsgBox "Printer Does not Exist" Elseif (oPrinters.Item (i))= NEW_PRINT_SERVER & strPrinterName Then MsgBox "New Printer Not Deleted" Else 'MsgBox "Removing " & oPrinters.Item (i) PrinterPath = oPrinters.Item (i) WshNetwork.RemovePrinterConnection PrinterPath End If Next WshNetwork.SetDefaultPrinter NEW_PRINT_SERVER & strDefault MsgBox "Your printers have been migrated!" Set WshNetwork = flaf
|
|
| |
|
|
|
 |
Re: Parsing lines from files and moveing dirs - 6/2/2005 1:06:07 AM
|
|
 |
|
| |
Netguard3
Posts: 14
Score: 0
Joined: 5/12/2005
From: Denmark
Status: offline
|
got it. Dim WS_Printers DefaultPrinterName = "" spoint = 0 SetDefault = 0 set WshShell = CreateObject("WScript.shell") from_sv = "\\servera" 'This should be the name of the old server. to_sv = "\\serverb" 'This should be the name of your new server. On Error Resume Next key = "HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows\Device" DefaultPrinter = LCase(WshShell.RegRead (key)) If Err.Number <> 0 Then DefaultPrinterName = "" else spoint = instr(3,DefaultPrinter,"\")+1 DefaultPrinterServer = left(DefaultPrinter,spoint-2) if DefaultPrinterServer = from_sv then DefaultPrinterName = mid(DefaultPrinter,spoint,len(DefaultPrinter)-spoint+1) end if end if Set WshNet = CreateObject("WScript.Network") Set WS_Printers = WshNet.EnumPrinterConnections For Loop_Counter = 0 To WS_Printers.Count - 1 Step 2 PrinterPath = lcase(WS_Printers(Loop_Counter + 1)) if LEFT(PrinterPath,len(from_sv)) = from_sv then spoint = instr(3,PrinterPath,"\")+1 PrinterName = mid(PrinterPath,spoint,len(PrinterPath)-spoint+1) WshNet.RemovePrinterConnection from_sv+"\"+PrinterName WshNet.AddWindowsPrinterConnection to_sv+"\"+PrinterName if DefaultPrinterName = PrinterName then WshNet.SetDefaultPrinter to_sv+"\"+PrinterName end if end if Next Set WS_Printers = Nothing Set WshNet = Nothing Set WshShell = Nothing
|
|
| |
|
|
|
| |
|
|
 |
|
 |
|
|