Page 2 of 3 <123>
Topic Options
#141882 - 2005-06-16 10:59 PM Re: Drive Mapping Capture
Co Offline
MM club member
***

Registered: 2000-11-20
Posts: 1338
Loc: NL
Search the board too. There are lots of examples. It is also the way to learn more about Kix..

Good luck!
_________________________
Co


Top
#141883 - 2005-06-17 06:43 AM Re: Drive Mapping Capture
Co Offline
MM club member
***

Registered: 2000-11-20
Posts: 1338
Loc: NL
We almost forgot this one:

EnumNetworkConnections() - Creates an Array/List of Network Connections
_________________________
Co


Top
#141884 - 2005-06-17 03:35 PM Re: Drive Mapping Capture
jhdvy Offline
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
#141885 - 2005-06-17 04:03 PM Re: Drive Mapping Capture
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
Everything you need to do what you want is there, you just need to put it together. You're asking for "silver platter" code and as volunteers we don't always have the time to put all of the code together for people.

Please understand that I'm not bashing you, just asking you to make the effort to understand the examples provided and put it together.

Top
#141886 - 2005-06-17 04:06 PM Re: Drive Mapping Capture
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
The function returns the output for you in an array. You just need to do var/string manipulation.

Some of the board regulars don't mind putting code on a silver platter for you, but you may get better results if you put forth an effort and actually try to do some of the coding yourself and then ask for help when you are stuck.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#141887 - 2005-06-17 04:09 PM Re: Drive Mapping Capture
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
ROFL
I should have hit refresh! Did not realize Chris posted almost the same thing I did. Great minds do think alike.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#141888 - 2005-06-30 05:53 PM Re: Drive Mapping Capture
jhdvy Offline
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
#141889 - 2005-06-30 06:20 PM Re: Drive Mapping Capture
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22332
Loc: OK
what you mean with label?
_________________________
!

download KiXnet

Top
#141890 - 2005-06-30 06:36 PM Re: Drive Mapping Capture
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
jhdvy,
Maybe if you showed us some of your code we might be able to grasp what it is you are trying to do. You have been offered at least four alternatives so far and I havent a clue which one you are working with and what you are trying to do.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#141891 - 2005-06-30 08:48 PM Re: Drive Mapping Capture
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11565
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
#141892 - 2005-07-01 12:12 AM Re: Drive Mapping Capture
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22332
Loc: OK
hmm...
that would be, if he really means the real label.
I was more thinking like he didn't know how to give a dynamic name to a variable.
_________________________
!

download KiXnet

Top
#141893 - 2005-07-01 12:17 AM Re: Drive Mapping Capture
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
My guess is he wants to put them in as keys in an INI file. Talk about three divergent interpretations!
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#141894 - 2005-07-01 01:12 AM Re: Drive Mapping Capture
StarwarsKid Offline
Seasoned Scripter
*****

Registered: 2005-06-15
Posts: 506
Loc: Oregon, USA
NTDOC, Could you clarify the timing issue you mentioned? Is there a way to prevent it? (I HOPE this doesn't qualify as hijaaking this post! )
_________________________
let the wise listen and add to their learning,
and let the discerning get guidance- Proverbs 1:5

Top
#141895 - 2005-07-01 06:46 PM Re: Drive Mapping Capture
jhdvy Offline
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. Offline
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
#141897 - 2005-07-01 11:45 PM Re: Drive Mapping Capture
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11162
Loc: Boston, MA, USA
There are a couple of MAPDRIVE() UDFs and a LABEL() UDF that enable you to apply custom labels to drive mappings.
_________________________
There are two types of vessels, submarines and targets.

Top
#141898 - 2005-07-02 08:40 AM Re: Drive Mapping Capture
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11565
Loc: CA
Think you missed what he was wanting Jens.

Code from Chris should handle what it appears to be he's looking for.

Top
#141899 - 2005-07-02 02:32 PM Re: Drive Mapping Capture
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11162
Loc: Boston, MA, USA
Yeah, guess so.
_________________________
There are two types of vessels, submarines and targets.

Top
#141900 - 2005-07-02 03:31 PM Re: Drive Mapping Capture
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Eh.. at least one of us interpreted it right.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#141901 - 2005-07-15 02:32 PM Re: Drive Mapping Capture
jhdvy Offline
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
Page 2 of 3 <123>


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 158 anonymous users online.
Newest Members
anhkfr, adamlevine, katherinknul, phamthuy, xuantu075
17631 Registered Users

Generated in 0.04 seconds in which 0.012 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org