Gerhard,

Gerhard Hofmann wrote:
Urs Rau wrote:

Hi Gerhard,

I have another question, about your excellent effort to create a scripted appsonly batch file.

Your "appsonly.pl" code currently has:

system("net user $autologinuser $autologinpwd /add /expires:never");
system("net localgroup Administratoren $autologinuser /add");
system("%z%\\bin\\autolog.pl --logon=1 --user=$autologinuser --password=$autologinpwd");


This doesn't really make sense.
There are two problems with this.

1. If you have rights to add somebody to the "Administratoren" group then you probably already are an Administrator.

2. The name "Administratoren" is one that MS have localized. So in this scenario it would be better to use their numeric security descriptor that is fixed across languages. S-1-5-32-544 (see http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q243330)

But more importantly, what were you trying to achieve? Can't we assume that the person doing the "appsonly.bat" will need to be a local or domain or enterprise admin and therefore we won't need these lines in? I for one surely wouldn't want to have normal user execute this script and also have them added to the local administrators group on their machine.


Hi Urs,

your objections are definitely right, so I'll need to explain why I did this. We have one very special case in our software repository: our business is to develop and sell our own ERP system that relies on the RDBMS Ingres (for those who don't know this product: it's something similar to Oracle, MS-SQL, MySQL...). We put Ingres on all our developper machines. In order to install Ingres it's necessary to create a user "ingres" that is part of local admin group. This was the motivation for me to add some function to appsonly.bat to create a new user. Probably, it is a much better idea to put the "net user..." command to my ingres.bat file.

I will change appsonly.bat like this:
1. it will ask if it should enable autologin
2. if user chooses autologin=y, it will ask for user and pwd
3. if user is unknown appsonly.bat will quit

Any idea how to determine existence of a user in a batch file?


I assume you would need this for your ingres bat file? Anyways DOS -
ERRORLEVEL returns are the answer for this, I think. See attached test2.ba_ (rename to test2.bat)


use as:

test2 net user Administrator
should return error level 0

test2 net user doesnotexist
should return error level 1

test2 net user /ADD doesnotexist
should retrun error level 0

test2 net user /ADD doesexist
should return error level 1

HTH.

Regards,


Urs Rau


------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click _______________________________________________ unattended-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/unattended-devel

Reply via email to