/build/static/layout/Breadcrumb_cap_w.png

InGroup Help with script

Hi, I've obtained this script which i need to customise, i have parts to this script what i'm trying to do is ie. if your InGroup "notebook user" goto first part of the scipt and if your Ingroup "Desktop" goto second part of the script.

Currently if your in the desktop group the scripts exits after reading the first line of the script

Thanks in advance...

reidd7
______________________________________________________________________________________________

If InGroup("Notebook User") <> 0

; Variable to catch the return value of several functions
Dim $Junk

; EXPLICIT: This option requires to DIM all variables used in your UDF, they will thus NOT
; conflict with any variable of the same name that has been created outside the UDF.
$Junk = SetOption("Explicit","On")

;NOVARSINSTRINGS: This option requires to not use variables within string delimiters.
$Junk = SetOption("NoVarsInStrings","On")

; CASESENSITIVITY: This option requires to compare strings by explicitly converting them
; to Lcase OR Ucase If you Do NOT want Case sensitivity to be a deciding factor.
$Junk = SetOption("CaseSensitivity","On")

; Set Workgroup Templates File Location for Office 2000
Dim $WorkgroupTemplates
$WorkgroupTemplates = "C:\Program Files\Microsoft Office\Templates\Forms2k"
; Is Office 2000 installed?
If KeyExist("HKEY_CURRENT_USER\Software\Microsoft\Office\9.0")
If KeyExist("HKEY_CURRENT_USER\Software\Microsoft\Office\9.0\Common\General")
; Does the Workgroup templates value exist?
$Junk = ReadValue("HKEY_CURRENT_USER\Software\Microsoft\Office\9.0\Common\General","SharedTemplates")
If Not @ERROR = 0
; If not, create it!
$Junk = WriteValue("HKEY_CURRENT_USER\Software\Microsoft\Office\9.0\Common\General","SharedTemplates",$WorkgroupTemplates,"REG_EXPAND_SZ")

EndIf




If InGroup("Desktop User") <> 0

; Variable to catch the return value of several functions
Dim $Junk

; EXPLICIT: This option requires to DIM all variables used in your UDF, they will thus NOT
; conflict with any variable of the same name that has been created outside the UDF.
$Junk = SetOption("Explicit","On")

;NOVARSINSTRINGS: This option requires to not use variables within string delimiters.
$Junk = SetOption("NoVarsInStrings","On")

; CASESENSITIVITY: This option requires to compare strings by explicitly converting them
; to Lcase OR Ucase If you Do NOT want Case sensitivity to be a deciding factor.
$Junk = SetOption("CaseSensitivity","On")

; Set Workgroup Templates File Location for Office 2000
Dim $WorkgroupTemplates
$WorkgroupTemplates = "f:\networkshare\folder"
; Is Office 2000 installed?
If KeyExist("HKEY_CURRENT_USER\Software\Microsoft\Office\9.0")
If KeyExist("HKEY_CURRENT_USER\Software\Microsoft\Office\9.0\Common\General")
; Does the Workgroup templates value exist?
$Junk = ReadValue("HKEY_CURRENT_USER\Software\Microsoft\Office\9.0\Common\General","SharedTemplates")
If Not @ERROR = 0
; If not, create it!
$Junk = WriteValue("HKEY_CURRENT_USER\Software\Microsoft\Office\9.0\Common\General","SharedTemplates",$WorkgroupTemplates,"REG_EXPAND_SZ")

EndIf

0 Comments   [ + ] Show comments

Answers (3)

Posted by: peska 18 years ago
Senior Yellow Belt
0
Hi reidd7,


Don't what scripting language you're using, looks a bit like Kixstart?!?
You're better off using WSH, I've written 2 scripts one in VBscript and one in Jscript for you.


'VBScript

'Function returns true if given context (user/computer) is member of given group
function MemberOf(groupName, className)

dim tmpStr
set adSysInfo = CreateObject("ADsystemInfo")
tmpStr = ""

If uCase(className) = "COMPUTER" Then
set obj = GetObject("LDAP://" & adSysInfo.ComputerName)
Else
set obj = GetObject("LDAP://" & adSysInfo.UserName)
End If

strGroups = UCase(Join(obj.MemberOf))
If InStr(strGroups, uCase(groupName)) Then
MemberOf = True
Else
MemberOf = False
End IF

End Function



Set wshShell = CreateObject("WScript.Shell")
Dim workgroupTemplates

'Do action if member of "Laptop User"
If MemberOf ("Laptop User","USER") Then
workgroupTemplates = "C:\Program Files\Microsoft Office\Templates\Forms2k"
End If

'Do Action if member of "Desktop User"
If MemberOf("Desktop User","USER") Then
workgroupTemplates = "f:\networkshare\folder"
End If

'Set groupTemplates
If not workgroupTemplates = "" Then
WshShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Office\9.0\Common\General\SharedTemplates",workgroupTemplates,"REG_EXPAND_SZ"
End If













//JScript

//Function returns true if given context (user/computer) is member of given group
function MemberOf(groupName, className)
{
tmpStr = "";
adSysInfo = new ActiveXObject("ADsystemInfo");

try
{
if((className != undefined) && (className.toUpperCase() == "COMPUTER"))
obj = GetObject("LDAP://"+adSysInfo.ComputerName);
else
obj = GetObject("LDAP://"+adSysInfo.UserName);
}
catch(e)
{
WScript.Quit(-1);
}

obj.GetInfo();

enumUserGrp = new Enumerator(obj.Groups());

for(;!enumUserGrp.atEnd();enumUserGrp.moveNext())
tmpStr = tmpStr + enumUserGrp.item().Name.toUpperCase();

if(tmpStr.indexOf(("CN=" + groupName).toUpperCase()) != -1)
return true;
else
return false;
}



wshShell = new ActiveXObject("WScript.Shell");
var workgroupTemplates = "";

//Do action If member of "Notebook User"
if(MemberOf("Notebook User","USER"))
workgroupTemplates = "C:\\Program Files\\Microsoft Office\\Templates\\Forms2k";

//Do action If member of "Desktop User"
if(MemberOf("Desktop User","USER"))
workgroupTemplates = "f:\\networkshare\\folder";

if(workgroupTemplates != "")
wshShell.RegWrite("HKEY_CURRENT_USER\\Software\\Microsoft\\Office\\9.0\\Common\\General\\SharedTemplates",workgroupTemplates,"REG_EXPAND_SZ");



Hope this helps you...


peska
Posted by: bartmanx04 18 years ago
Yellow Belt
0
I need help. I am trying to create a silent install of a program that only has certain windows controlled by the install shield. The rest are controlled by I don't know what. I am using command lines /r and /s to create a answer file. Any suggsstions? Any help would be appreciated. Thank You!!!
Posted by: aogilmor 18 years ago
9th Degree Black Belt
0
for one thing, you should probably post this in Package Development. The script forum here seems pretty dead (no offense to anybody, just not a lot of posts)

but to answer your question, you can create an answer file, but that's kind of an outmoded way of installing an app, and prone to errors. as you may have seen already. if you must stick with that method, and you're running into problems, you can visit the installshield kb, which is now part of macromedia. google it. your other option might be to repackage the app using Wise or some other tool. Hope this helps.
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ