Page 1 of 1 1
Topic Options
#127942 - 2004-10-15 01:50 AM if ingroup, vbs, drive mapping
JoS Offline
Fresh Scripter

Registered: 2004-10-14
Posts: 6
greetings --

(this is long and maybe complicated)

currently i have a kix script that calls a vbscript, to wit:

if ingroup("GroupA")
run ("cscript.exe \\server\share$\groupA.vbs")
endif

and groupA.vbs looks like:

'map drives
On Error Resume Next
Dim WshNetwork
Set WshNetwork = WScript.CreateObject("WScript.Network")

WshNetwork.MapNetworkDrive "g:", "\\server\share$\groupA"

set WshShell = WScript.CreateObject("WScript.Shell")
strDesktop = WshShell.SpecialFolders("Desktop")
set oShellLink = WshShell.CreateShortcut(strDesktop & "\Group Share.lnk")
oShellLink.TargetPath = WScript.ScriptFullName
oShellLink.WindowStyle = 1
oShellLink.TargetPath = "G:\"
oShellLink.WorkingDirectory = "G:\"
oShellLink.Save

basically this maps drive G:\ to the groupA share and drops a shortcut on the desktop to drive G:\

this works fine but what i would like to do is have 1 vbscript that uses the groupname variable to map the drive and shortcut (so i don't have to create a seperate vbscript for each domain group).

so, can i pass the groupname variable from the kix script to the vbscript? or more ideally - do the entire thing in kix?

thanks for the time and i hope this makes sense!

JoS

Top
#127943 - 2004-10-15 02:02 AM Re: if ingroup, vbs, drive mapping
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
First off, RUN is a command, not a function and as such the parens are not needed.

Second, why VBS when you can do it all in KiX?
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#127944 - 2004-10-15 02:28 AM Re: if ingroup, vbs, drive mapping
JoS Offline
Fresh Scripter

Registered: 2004-10-14
Posts: 6
yeah - kix is new to me ... i will axe the parens. do you have any resources that i would find handy for converting that vbs to kix?

tia

Top
#127945 - 2004-10-15 02:51 AM Re: if ingroup, vbs, drive mapping
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Often, converting VBS to Kix is as easy as putting $ in front of the vars replacing & with +, and taking out the spaces between END IF. There is even a UDF posted that does it. There are also lots of examples posted on the board.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#127946 - 2004-10-15 02:56 AM Re: if ingroup, vbs, drive mapping
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Actually, everything you are doing is available natively in KiX without "converting" the WSH.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#127947 - 2004-10-15 03:03 AM Re: if ingroup, vbs, drive mapping
JoS Offline
Fresh Scripter

Registered: 2004-10-14
Posts: 6
les - great! thanks for the info

i will give it a shot and post back if i need assistance.

Top
#127948 - 2004-10-15 03:06 AM Re: if ingroup, vbs, drive mapping
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
Heres some sample code for you to check out. All in Kix as Les mentioned. The wshshortcut udf came straight from the udf forum here on the board.

Code:

If InGroup("GroupA")
Use G: /Delete /Persistent
Use G: "\\server\share$\groupA"
WshShortCut("%userprofile%\desktop\G Drive.lnk","G:\")
Endif

If InGroup("GroupB")
Use H: /Delete /Persistent
Use H: "\\server\share$\groupB"
WshShortCut("%userprofile%\desktop\H Drive.lnk","H:\")
Endif

function WshShortCut($path,$targetpath,optional $arguments,optional

$startdir,optional $iconpath,optional $style)
dim $shell,$shortcut
$shell=createobject("wscript.shell")
if $shell
$shortcut=$shell.createshortcut($path)
if $shortcut
$shortcut.targetpath=$targetpath
if $arguments
$shortcut.arguments=$arguments
endif
if $startdir
$shortcut.workingdirectory=$startdir
endif
if $iconpath
$shortcut.iconlocation=$iconpath
endif
if $style
$shortcut.windowstyle=$style
endif
$shortcut.save
$shortcut=0
endif
$shell=0
endif
exit @error
endfunction


Top
#127949 - 2004-10-16 02:06 AM Re: if ingroup, vbs, drive mapping
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
And the KiXtart Manual would be a very good resource for converting the VBS code to KiXtart. Additionally, the UDF Forum has over 400 ready-made UDFs that should cover you as well.
_________________________
There are two types of vessels, submarines and targets.

Top
#127950 - 2004-10-20 08:24 PM Re: if ingroup, vbs, drive mapping
JoS Offline
Fresh Scripter

Registered: 2004-10-14
Posts: 6
i would like to thank this forum! i was able to do the entire script in kix.

again many thanks for the help

Top
Page 1 of 1 1


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 194 anonymous users online.
Newest Members
BeeEm, min_seow, Audio, Hoschi, Comet
17882 Registered Users

Generated in 0.143 seconds in which 0.112 seconds were spent on a total of 12 queries. Zlib compression enabled.

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