#141883 - 2005-06-17 06:43 AM
Re: Drive Mapping Capture
|
Co
MM club member
Registered: 2000-11-20
Posts: 1341
Loc: NL
|
|
Top
|
|
|
|
#141884 - 2005-06-17 03:35 PM
Re: Drive Mapping Capture
|
jhdvy
Fresh Scripter
Registered: 2002-03-22
Posts: 44
Loc: New Jersey
|
How do I get an output from the above function? Also, in the fso example, is there a way to label the connection as network connection 1 = j: \\server\share, network connection 2 = m: \\server\share.
Thanks
|
Top
|
|
|
|
#141888 - 2005-06-30 05:53 PM
Re: Drive Mapping Capture
|
jhdvy
Fresh Scripter
Registered: 2002-03-22
Posts: 44
Loc: New Jersey
|
Ok, I've tried to make this work for about 2 weeks now but haven't had much luck labeling the connection as network connection1=\\server\share network connection2=\\server\share
Anyone care to shed some light on how to do this?
Thanks
|
Top
|
|
|
|
#141891 - 2005-06-30 08:48 PM
Re: Drive Mapping Capture
|
NTDOC
Administrator
Registered: 2000-07-28
Posts: 11623
Loc: CA
|
Well using something like this works, but there are "timing" issues which might prevent the label from working all the time.
MapDrive('T','\\SERVER01\FILESHARE','IT Support',,1,0)
That would place a label of 'IT Support' on the T drive when mapped using the MapDrive UDF
Code:
Function MapDrive($DriveLetter,$UNC,optional $Label,$Icon,$Delete,$Persistent) Dim $,$D,$Di,$Per,$Shell $D = Left($DriveLetter,1) $Di= 'HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\DriveIcons' If $Delete Use $D+':' /DELETE /PERSISTENT If $Admin $=DelTree($Di+'\'+$D) EndIf EndIf If $Persistent Use $D+':' $UNC /PERSISTENT Else Use $D+':' $UNC EndIf If Not Exist($D+':\') Exit 1 EndIf If $Label $Shell=CreateObject("shell.application") If @ERROR Exit @ERROR EndIf $Shell.namespace($D+':\').self.name=$Label EndIf If $Admin If $Icon $=WriteValue($Di+'\'+$D+'\DefaultIcon','',$Icon,REG_SZ) EndIf EndIf Exit @ERROR EndFunction
|
Top
|
|
|
|
#141895 - 2005-07-01 06:46 PM
Re: Drive Mapping Capture
|
jhdvy
Fresh Scripter
Registered: 2002-03-22
Posts: 44
Loc: New Jersey
|
All I would like to be able to do is list each network drive in an .ini file. Example.. If I have 3 drives mapped J, K and L, I would like to write it to my .ini file as network drive1=J \\server\share netowrk drive2=K \\server\share network drive3=L \\server\share
I'm using the fso solution to capture the mappings. Dim $fso, $d, $dc $fso = CreateObject("Scripting.FileSystemObject") $dc = $fso.Drives For Each $d In $dc If $d.DriveType = 3 $d.DriveLetter "=" + $d.ShareName? EndIf Next
|
Top
|
|
|
|
#141896 - 2005-07-01 07:16 PM
Re: Drive Mapping Capture
|
Chris S.
MM club member
Registered: 2002-03-18
Posts: 2368
Loc: Earth
|
This works for me...
Code:
Dim $fso, $d, $dc $fso = CreateObject("Scripting.FileSystemObject") $dc = $fso.Drives For Each $d in $dc If $d.DriveType = 3 If WriteProfileString(@SCRIPTDIR+"\netdrives.ini","DRIVES",$d.DriveLetter,$d.ShareName) "Error: " + @ERROR + ' | ' + @SERROR ? EndIf EndIf Next
|
Top
|
|
|
|
#141901 - 2005-07-15 02:32 PM
Re: Drive Mapping Capture
|
jhdvy
Fresh Scripter
Registered: 2002-03-22
Posts: 44
Loc: New Jersey
|
Here is what I have so far. I doesn't look too good but it works. Any recommendations are appreciated. Please go easy on me I'm fairly new to kix. Code:
If @DOS = "4.0" GoTo "END" Else If @DOS = "5.0" OR "5.01" GoTo "BEGIN" EndIf EndIf
:Begin If NOT Exist ("\\server\share\" + @WkSta + ".ini") GoTo "Step1" Else GoTo "Step2" EndIf
:Step1 ?"Getting Hardware and Software Inventory. Please wait......" $wsinfofile = "\\server\share\" + @WkSta + ".ini" $rc = WriteProfileString("$WSInfoFile","WsInfo","User Name","@FullName") $rc = WriteProfileString("$WSInfoFile","WsInfo","UserID","@Userid") $rc = WriteProfileString("$WSInfoFile","WsInfo","WS Domain","@DOMAIN") $rc = WriteProfileString("$WSInfoFile","WsInfo","Login Domain","@LDOMAIN") $rc = WriteProfileString("$WSInfoFile","WsInfo","WsName","@WkSta") $rc = WriteProfileString("$WSInfoFile","WsInfo","IPAddress","@ipaddress0") $rc = WriteProfileString("$WSInfoFile","WsInfo","Date","@month @mdayno @year @time")
If RedirectOutput("\\server\share\" + @WkSta + ".ini") = 0 ? "The following is System and Hardware Info:" ? "System Name = "WMIQuery("CSName","Win32_OperatingSystem") ? "OS Name = "WMIQuery("Caption","Win32_OperatingSystem") ? "Manufacturer = "WMIQuery("Manufacturer","Win32_OperatingSystem") ? "OS Version Number = "WMIQuery("Version","Win32_OperatingSystem") ? "OS Build Number = "WMIQuery("BuildNumber","Win32_OperatingSystem") ? "OS Build Type = "WMIQuery("BuildType","Win32_OperatingSystem") ? "Language = "WMIQuery("OSLanguage","Win32_OperatingSystem") ? "Service Pack = "WMIQuery("CSDVersion","Win32_OperatingSystem") ? "Boot Device = "WMIQuery("BootDevice","Win32_OperatingSystem") ? "System Device = "WMIQuery("SystemDevice","Win32_OperatingSystem") ? "Windows Directory = "WMIQuery("WindowsDirectory","Win32_OperatingSystem") ? "System Directory = "WMIQuery("SystemDirectory","Win32_OperatingSystem") ? "Install Date = "WMIQuery("InstallDate","Win32_OperatingSystem") ? "Last Boot Time = "WMIQuery("LastBootupTime","Win32_OperatingSystem") ? "Registered User = "WMIQuery("RegisteredUser","Win32_OperatingSystem") ? "Registered Organization = "WMIQuery("Organization","Win32_OperatingSystem") ? "OS Serial Number = "WMIQuery("SerialNumber","Win32_OperatingSystem") ? "System Manufacturer is = "WMIQuery("Manufacturer","Win32_ComputerSystem") ? "System Model is = "WMIQuery("Model","Win32_ComputerSystem") ? "System Serial Number is = "WMIQuery("SerialNumber","Win32_BIOS") ? "System BIOS Version is = "WMIQuery("SMBIOSBIOSVersion","Win32_BIOS") ? "System BIOS Date is = "WMIQuery("Version","Win32_BIOS") ? "CPU Manufacturer: = "WMIQuery("manufacturer","Win32_Processor") ? "Description: = "WMIQuery("description","Win32_Processor") ? "CPU Speed is = "WMIQuery("CurrentClockSpeed","Win32_Processor") " Mhz" ? "Maximum Clock Speed = "WMIQuery("maxclockspeed","Win32_Processor") " Mhz" ? "L2 Cache Size: = "WMIQuery("l2cachesize","Win32_Processor") ? "L2 Cache Speed: = "WMIQuery("l2cachespeed","Win32_Processor") ? "Family: = "WMIQuery("family","Win32_Processor") ? "Level: = "WMIQuery("level","Win32_Processor") ? "Stepping: = "WMIQuery("stepping","Win32_Processor") ? "Device ID: = "WMIQuery("deviceid","Win32_Processor") ? "Unique ID: = "WMIQuery("uniqueid","Win32_Processor") ? "System Memory = "Val(WMIQuery("TotalPhysicalMemory","Win32_LogicalMemoryConfiguration"))/1024 " MB" For Each $dimm In Split(WMIQuery("Capacity","Win32_PhysicalMemory"),"|") ? "Dimm Size = "Val($dimm) / 1048576 " MB" Next ;? "Disk Name/s = "WMIQuery("name","Win32_LogicalDisk") ;? "Volume Name = "WMIQuery("volumename","Win32_LogicalDisk")" MB" ? "Size = "WMIQuery("size","Win32_diskdrive") " MB" ? "File System = "WMIQuery("filesystem","Win32_diskdrive") ;? "Free Space = "WMIQuery("freespace","Win32_LogicalDisk")" MB" ? "Video Card is = "WMIQuery("Description","Win32_VideoController") ? "Video Res is = "WMIQuery("VideoModeDescription","Win32_VideoController") ? "Modem is = "WMIQuery("Description","Win32_POTSModem") ;for each $ptr in Split(WMIQuery("Name","Win32_printer"),"|") ; ? "Connected Printer is = "$ptr ;next ;for each $nic in Split(WMIQuery("ProductName","Win32_NetworkAdapter"),"|") ; if instr($nic,"miniport")=0 and instr($nic,"RAS")=0 and instr($nic,"Parallel")=0 ; ? "Network Card is = "$nic ; endif ;next
?"Network Drives" ? Dim $fso, $d, $dc $fso = CreateObject("Scripting.FileSystemObject") $dc = $fso.Drives For Each $d In $dc If $d.DriveType = 3 $d.DriveLetter "=" + $d.ShareName? EndIf Next
?'The following is Software Info:' $InstalledSoftwareArray=GetSoftwareList(1) For Each $element In $InstalledSoftwareArray ?$element Next
Function GetSoftwareList(OPTIONAL $Sort) ; Author: ScriptLogic Corporation ; Last revised: 16-nov-2001 ; Optional parameter: sort ; if 0 (or not supplied), no sorting of list is done. ; if 1, results are sorted alphabetically, ascending order ; Note: If sorting is requested, this function then has a ; dependency on the Asort( ) UDF. Dim $ArrayIndex, $EnumIndex, $Component, $DN, $RegKey, $SwArray[200] $RegKey='HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall' $EnumIndex=0 $ArrayIndex=0 :gisloop $Component=EnumKey($RegKey, $EnumIndex) If NOT @Error ;if not (len($Component)=7 and left($Component,1)='Q') ; above line excludes hotfixes from listing If NOT (0+ReadValue($RegKey+'\'+$Component,'SystemComponent')) $DN=ReadValue($RegKey+'\'+$Component,'DisplayName') If $DN $SwArray[$ArrayIndex]=$DN $ArrayIndex=$ArrayIndex+1 EndIf EndIf $EnumIndex=$EnumIndex+1 GoTo gisloop ;endif EndIf ReDim preserve $SwArray[$ArrayIndex] If $Sort $GetSoftwareList=Asort($SwArray) Else $GetSoftwareList=$SwArray EndIf EndFunction
Function ASort($array, OPTIONAL $order) ; sort order: 0 = ascending, 1 = decending Dim $index, $x, $y, $tmp, $changed $Asort=$array $order=0+$order Do $changed=0 For $index = 0 to Ubound($asort)-1 $x=$asort[$index] $y=$asort[$index+1] If ($x > $y AND 1-$order) OR ($x < $y AND $order) $tmp=$x $asort[$index]=$y $asort[$index+1]=$tmp $changed=1 EndIf Next Until $changed=0 EndFunction
Function WMIQuery($what,$where,) Dim $strQuery, $objEnumerator, $value $strQuery = "Select $what From $where" $SystemSet = GetObject("winmgmts:{impersonationLevel=impersonate}!//@WKSTA") $objEnumerator = $SystemSet.ExecQuery($strQuery) For Each $objInstance In $objEnumerator If @Error = 0 AND $objInstance <> "" $=Execute("$$value = $$objInstance.$what") $WMIQuery="$value"+"|"+"$WMIQuery" EndIf Next $WMIQuery=Left($WMIQuery,Len($WMIQuery)-1) Exit @error EndFunction $computer = @wksta ;? WMIQuery2("Services on","Win32_Service") ;? WMIQuery2("Processes on","Win32_Process") Function WMIQuery2($what,$where,) $wmi = GetObject("winmgmts:{impersonationLevel=impersonate}!//" + $computer + "/root/cimv2") $list = "" $objs = $wmi.instancesof($where) For Each $obj In $objs $list = $list + $obj.description + Chr(13) + Chr(10) Next $list=Left($list, Len($list)) ?$what +" "+ $computer + Chr(13) + Chr(10) + $list EndFunction If RedirectOutput("")=0 EndIf
:Step2 $wsinfofile = "\\server\share\" + @WkSta + ".ini" $rc = WriteProfileString("$WSInfoFile","WsInfo","User Name","@FullName") $rc = WriteProfileString("$WSInfoFile","WsInfo","UserID","@Userid") $rc = WriteProfileString("$WSInfoFile","WsInfo","WS Domain","@DOMAIN") $rc = WriteProfileString("$WSInfoFile","WsInfo","Login Domain","@LDOMAIN") $rc = WriteProfileString("$WSInfoFile","WsInfo","WsName","@WkSta") $rc = WriteProfileString("$WSInfoFile","WsInfo","IPAddress","@ipaddress0") $rc = WriteProfileString("$WSInfoFile","WsInfo","Date","@month @mdayno @year @time")
:END
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 515 anonymous users online.
|
|
|