#138112 - 2005-04-18 07:07 PM
Converting VBScript to KIX
|
tdiehm
Lurker
Registered: 2005-04-18
Posts: 3
|
Hi all,
I'm trying to convert this VBScript to KIX so I can enter it into a larger KIX file. I saw this thread at http://www.kixtart.org/ubbthreads/showflat.php?Cat=&Board=UBB12&Number=83646 on how to convert but I'm not sure how to get it to run. Do I just put it in a batch file???
Any help would be appreciated, the actual code is below. Basically it's just a script to add/remove printers.
Thanks.
On Error Resume Next
DIM FSO, WshSysEnv, WshNetwork, objSysInfo, objUser DIM strVersion, objPrintVer
strVersion = "004"
Set FSO=CreateObject ("Scripting.FileSystemObject") Set WshSysEnv = WshShell.Environment("PROCESS") Set WshNetwork = WScript.CreateObject("WScript.Network") Set objSysInfo = CreateObject("ADSystemInfo") Set objUser = GetObject ("LDAP://" & objSysInfo.UserName)
'If Not FSO.FileExists (WshSysEnv("USERPROFILE") & "\printver." & strVersion) Then If Not FSO.FileExists ("c:\printver." & strVersion) Then
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Remove all networked printers strComputer = "." Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colInstalledPrinters = objWMIService.ExecQuery("Select * from Win32_Printer") For Each objPrinter in colInstalledPrinters If Left(objPrinter.Name,2) = "\\" Then WshNetwork.RemovePrinterConnection objPrinter.Name End If Next
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' General printers
strPrinterPath = "\\FILE01\HP5100dtn" WshNetwork.AddWindowsPrinterConnection strPrinterPath If ChkGroup("PAWM01.HP5100dtn") Then Wscript.Sleep 2000 WshNetwork.SetDefaultPrinter strPrinterPath End If
strPrinterPath = "\\FILE01\WARM-HP4000" WshNetwork.AddWindowsPrinterConnection strPrinterPath If ChkGroup("PAWM01.HP4000") Then Wscript.Sleep 2000 WshNetwork.SetDefaultPrinter strPrinterPath End If strPrinterPath = "\\FILE01\WARM-HP4M" WshNetwork.AddWindowsPrinterConnection strPrinterPath If ChkGroup("PAWM01.HP4M") Then Wscript.Sleep 2000 WshNetwork.SetDefaultPrinter strPrinterPath End If
strPrinterPath = "\\FILE01\WARM-HP4MV" WshNetwork.AddWindowsPrinterConnection strPrinterPath If ChkGroup("PAWM01.HP4MV") Then Wscript.Sleep 2000 WshNetwork.SetDefaultPrinter strPrinterPath End If
strPrinterPath = "\\FILE01\XeroxDoc" WshNetwork.AddWindowsPrinterConnection strPrinterPath If ChkGroup("PAWM01.XeroxColor") Then Wscript.Sleep 2000 WshNetwork.SetDefaultPrinter strPrinterPath End If
Set objPrintVer = FSO.CreateTextFile ("c:\printver." & strVersion, True, False) objPrintVer.Writeline ("This is a flag file... if deleted the PAWM01-P.VBS script will execute again.") objPrintVer.Close Set objPrintVer = Noting
End If
Set FSO = Nothing Set WshSysEnv = Nothing Set WshNetwork = Nothing Set objSysInfo = Nothing Set objUser = Nothing strVersion = ""
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Function to check membership of a group Function ChkGroup(strGroup)
ChkGroup = False On Error Resume Next Set oGroup = GetObject("WinNT://AI-ENGSVCS/" & strGroup) If Err.Number >= 0 Then
Set objSysInfo = CreateObject("ADSystemInfo") Set objUser = GetObject ("LDAP://" & objSysInfo.UserName)
If oGroup.IsMember("WinNT://TESTDOMAIN/" & Right(objUser.Name,Len(objUser.Name) -3)) Then chkGroup = True End If
Set oGroup = Nothing Set objUser = Nothing Set objSysInfo = Nothing
End If
End Function
|
|
Top
|
|
|
|
#138114 - 2005-04-18 07:47 PM
Re: Converting VBScript to KIX
|
tdiehm
Lurker
Registered: 2005-04-18
Posts: 3
|
Quote:
From what I see of that VBS, KiX can do it natively so there is no neet to convert it to KiX COM.
So does that mean I can just insert that code into my larger KiX file? I thought I read that KiX and VBS language were similar but didn't realize that I wouldn't have to change anything.
|
|
Top
|
|
|
|
#138117 - 2005-04-19 06:44 PM
Re: Converting VBScript to KIX
|
tdiehm
Lurker
Registered: 2005-04-18
Posts: 3
|
Cool, thanks for the info all!
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 2220 anonymous users online.
|
|
|