This website uses cookies. By clicking Accept, you consent to the use of cookies. Click Here to learn more about how we use cookies.
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
- Revenera Community
- :
- InstallShield
- :
- InstallShield Forum
- :
- Re: How can I check in InstallScript that a username exists
Subscribe
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Nov 16, 2007
02:12 AM
How can I check in InstallScript that a username exists
Hi all,
I only need to check that a specific username is already defined in the installed machine.
Must I check registry or is there some better way to do it ?
Regards
Jarmo
I only need to check that a specific username is already defined in the installed machine.
Must I check registry or is there some better way to do it ?
Regards
Jarmo
(2) Replies
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Nov 22, 2007
05:10 AM
I did not found any better solution.
I started "net user" command and redirected output to a temporary file and modified it a little with vbs script and checked if the username exists in that file.
Seems to work :cool:
I started "net user" command and redirected output to a temporary file and modified it a little with vbs script and checked if the username exists in that file.
Seems to work :cool:
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Nov 23, 2007
02:33 AM
Hi,
Hm i'm not a expert in installshield but for to verify is a user exist you can use the API windows :Netapi32.dll
In one of my basic msi project, i have a dialog with 3 text box :domain, user and password.
People who installs my product can enter a domain\username and password or specify a local user ComputerName\User name and password
when we click on next button i call a function in a dll (dotnet) with some code installscript.
This function return OK or KO and of course i have a condtion on the next button 🙂 if the user exist i call new dialog ReaduToInstall if the user doesn't exist i send a message !
Here is it some code, this function is OK on palteform win 2000, xp, 2003 and vista
[CODE]
//add this using
using System;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using System.DirectoryServices;
namespace ...
{
//Load the API
[DllImport("Netapi32.dll")]
extern static int NetUserChangePassword([MarshalAs(UnmanagedType.LPWStr)] string domainname,[MarshalAs(UnmanagedType.LPWStr)] string username,[MarshalAs(UnmanagedType.LPWStr)] string oldpassword,[MarshalAs(UnmanagedType.LPWStr)] string newpassword);
//THE METHOD
public string CheckUser(string domain, string username, string password)
{
string valeur;
valeur = "KO";
int ret;
//Function NetUserChangePassword(domain ,user ,password ,new password)
ret = NetUserChangePassword( domain, username, password, password );
if (ret != 0 && ret != 1327 && ret != 2245)
{
valeur = "KO";
//valeur = string.Format("KO - ret = {0} -{1}-{2}-{3}-", ret, domain, username, password);
MessageBox.Show("Return code: " + ret.ToString());
}
else
{
valeur = "OK";
//valeur = string.Format("OK - ret = {0} -{1}-{2}-{3}-", ret, domain, username, password);
MessageBox.Show("Return code: " + ret.ToString());
}
return valeur;
}
....
[/CODE]
and in the basic msi project , installscript code use the function dotnetcocreatobject
As you can see , we use the fonction NetUserChangePassword but don't be afraid we don't change the password !
Hope this few sentence help you
Christophe
Hm i'm not a expert in installshield but for to verify is a user exist you can use the API windows :Netapi32.dll
In one of my basic msi project, i have a dialog with 3 text box :domain, user and password.
People who installs my product can enter a domain\username and password or specify a local user ComputerName\User name and password
when we click on next button i call a function in a dll (dotnet) with some code installscript.
This function return OK or KO and of course i have a condtion on the next button 🙂 if the user exist i call new dialog ReaduToInstall if the user doesn't exist i send a message !
Here is it some code, this function is OK on palteform win 2000, xp, 2003 and vista
[CODE]
//add this using
using System;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using System.DirectoryServices;
namespace ...
{
//Load the API
[DllImport("Netapi32.dll")]
extern static int NetUserChangePassword([MarshalAs(UnmanagedType.LPWStr)] string domainname,[MarshalAs(UnmanagedType.LPWStr)] string username,[MarshalAs(UnmanagedType.LPWStr)] string oldpassword,[MarshalAs(UnmanagedType.LPWStr)] string newpassword);
//THE METHOD
public string CheckUser(string domain, string username, string password)
{
string valeur;
valeur = "KO";
int ret;
//Function NetUserChangePassword(domain ,user ,password ,new password)
ret = NetUserChangePassword( domain, username, password, password );
if (ret != 0 && ret != 1327 && ret != 2245)
{
valeur = "KO";
//valeur = string.Format("KO - ret = {0} -{1}-{2}-{3}-", ret, domain, username, password);
MessageBox.Show("Return code: " + ret.ToString());
}
else
{
valeur = "OK";
//valeur = string.Format("OK - ret = {0} -{1}-{2}-{3}-", ret, domain, username, password);
MessageBox.Show("Return code: " + ret.ToString());
}
return valeur;
}
....
[/CODE]
and in the basic msi project , installscript code use the function dotnetcocreatobject
//Call the dll with 3 parameters in the sourcedir
set objectUserLogon = DotNetCoCreateObject(szPathCompletDll, "CheckUserLogon.CheckUserLogon", "");
//CALL the method in the dll dotnet
try
szRet = objectUserLogon.CheckUser( szWinDomain, szWinUser, szWinPass );
//MessageBox(szRet, INFORMATION);
if (szRet = "OK") then
//MessageBox("LogonUser successful!", INFORMATION);
MsiSetProperty(hMSI,"MYPROPERTY", "OK");
.....
As you can see , we use the fonction NetUserChangePassword but don't be afraid we don't change the password !
Hope this few sentence help you
Christophe