Page 1 of 1 1
Topic Options
#70706 - 2002-10-08 06:13 PM su.exe question
cj06 Offline
Fresh Scripter

Registered: 2002-09-26
Posts: 7
This is related to my question posted yesterday.
When trying to avoid a password-prompt when using su.exe, the W2K resource kit says that you can avoid the prompt by typing the following:
su username < c:\password\username.txt
The password for user username is obtained from c:\password\username.txt. The password must be followed by a carriage return in the file username.txt.
Can someone help me by typing an example to help me to get this to work? I don't know what symbol or character to type in the "username.txt" file related to "carriage Return"
Thanks.

Top
#70707 - 2002-10-08 06:15 PM Re: su.exe question
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
well, I thought you got pretty good answers already yesterday.

have you tried them?
 
_________________________
!

download KiXnet

Top
#70708 - 2002-10-08 06:32 PM Re: su.exe question
avazquez49 Offline
Fresh Scripter

Registered: 2002-10-07
Posts: 6
Loc: Ohio
Don't use Notepad if you are trying to do carriage returns.

Try using the DOS Edit Program.

Top
#70709 - 2002-10-08 06:38 PM Re: su.exe question
cj06 Offline
Fresh Scripter

Registered: 2002-09-26
Posts: 7
Yes, I tried all the suggestions and all of them were good ones, but they do not seem to work.
Top
#70710 - 2002-10-08 06:53 PM Re: su.exe question
Waltz Offline
Seasoned Scripter

Registered: 2002-08-01
Posts: 485
Loc: Waterloo, Ontario, Canada
Type in the name and hit {Enter}

The {Enter} key thingies are CR (hex OD) and LF (hex OA) and are there, but 'invisible'.

To satisfy yourself you can save the file in text format and then open it with a Hex Editor.. You will see the {Enter} characters "od" and "oa" after the name.

For example: The username is Nosmo KIng

Using a text editor(e.g. notepad.exe), you will see...
code:
Nosmo King

(and your cursor will be at the start of this line)

Using a hex editor(e.g. phred.exe), you will see...
code:
4e 6f 73 6d 6f 20 4b 69 6e 67 0d 0a 

If you do the ASCII chart lookup for these hex values you can see the 'translations'...4e is uppercase N, 6f is lowercase o, and so on and the {Enter} key is represented by the 0d 0a at the end.

[ 11. October 2002, 14:03: Message edited by: Waltz ]
_________________________
We all live in a Yellow Subroutine...

Top
#70711 - 2002-10-08 07:00 PM Re: su.exe question
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
mmm...
just memorizing these things...
what about:
echo password | su username

haven't tried as never needed the su...
_________________________
!

download KiXnet

Top
#70712 - 2002-10-08 07:15 PM Re: su.exe question
Waltz Offline
Seasoned Scripter

Registered: 2002-08-01
Posts: 485
Loc: Waterloo, Ontario, Canada
cjo6...
Q: Are you trying to do this from a batch file called by a kix script?
_________________________
We all live in a Yellow Subroutine...

Top
#70713 - 2002-10-08 07:18 PM Re: su.exe question
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
cj06,
Show us the whole line that calls SU. I suspect you may have omitted the %comspec% which is needed for redirect '<' to work.

I don't (won't) use SU because of the security risk but read somewhere the using enviro vars is the way to go. Personally I'd use Task Scheduler.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#70714 - 2002-10-08 07:44 PM Re: su.exe question
Waltz Offline
Seasoned Scripter

Registered: 2002-08-01
Posts: 485
Loc: Waterloo, Ontario, Canada
{Edit}I think Les has pegged it. The username.txt file is probably not the culprit.{/Edit}

How about...

code:
"%comspec% /q /e:1024 /c su.exe username < c:\username.txt" 

or using an env var in batch...
code:
set su_username=Nosmo King
su.exe username



[ 08. October 2002, 19:47: Message edited by: Waltz ]
_________________________
We all live in a Yellow Subroutine...

Top
#70715 - 2002-10-08 07:45 PM Re: su.exe question
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
And please search the KiXtart BBS for examples of how to use SU.EXe. There have been a couple of examples already posted.
_________________________
There are two types of vessels, submarines and targets.

Top
#70716 - 2002-10-09 08:47 PM Re: su.exe question
cj06 Offline
Fresh Scripter

Registered: 2002-09-26
Posts: 7
Everyone, thanks for the responses.
Waltz was correct with his suggestions.
In my kix file I have:
shell "cmd /c su administrator < c:\winnt\pw.txt "executable.exe" -w
In the pw.txt file, I typed in the admin password and hit enter at the end of the word.
Fo security purposes, I like this method the best because the password is stored in a file on the hard drive. Users will unlikely stumble upon it and open it.
If you put it in an environmental variable, the user can see what it is by System, Advanced, Environmental Variables.
If you do the echo password | username method then the password is exposed in the netlogon share and you probabably don't want other people to look at it if you are on a pretty large domain with multiple people accessing the share to add their files to work with their OU in AD.

Top
#70717 - 2002-10-09 10:21 PM Re: su.exe question
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
You cna delete the content of an environment variable at the end of your script. However, sinc ethe password is still plain-text it's not really secure. There are examples on this board using SU.EXe with encrypted passwords. Alternatively, you might want to use the Taks Scheduler since that one stores the password in encrypted form and it can be scheduled remotely, thus not storing anything on the user's computer.
_________________________
There are two types of vessels, submarines and targets.

Top
#70718 - 2002-10-10 02:23 AM Re: su.exe question
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
cj06,
I wouldn't exactly call that secure. Putting the password on the users' C: drive and then telling them where to look with this line:

shell "cmd /c su administrator < c:\winnt\pw.txt "executable.exe" -w

That's what I call security by ignorance!

Hmmm, have to wonder just how much of the store you're giving away with that password...
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#70719 - 2002-10-10 04:30 AM Re: su.exe question
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
To be hones, I haven't yet found any reason to use SU.EXE since I can accomplish all local administratvie tasks with the Task Scheduler. The added advantage of the Task Scheduler is that if you are using another user account, then the current user doesn't even see the scheduled scripts running. Thus, you can perform tasks at the same time as a user is logged in without him noticing (unless, of course, you take away all his bandwidth or CPU cycles).

[ 14. October 2002, 21:42: Message edited by: sealeopard ]
_________________________
There are two types of vessels, submarines and targets.

Top
#70720 - 2002-10-10 07:00 AM Re: su.exe question
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
and if he notices, he can do nothing to stop but turn the power off from switch.
and after it's on again you are back...

I love that.
they can run but they can not hide.
 
_________________________
!

download KiXnet

Top
#70721 - 2002-10-14 09:06 PM Re: su.exe question
cj06 Offline
Fresh Scripter

Registered: 2002-09-26
Posts: 7
LLigetfa, login scripts don't run visible when you are in a W2K shop. The text is suppressed. That's probably why I didn't think of that since no one uses w9X here anymore.
As far as using task scheduler instead of su. If anyone knows how to get ts to recognize an autoit script saved as an .exe file let me know. Otherwise I'll use su to run the autoit scripts since I use them to run W2K critical updates when users log on.

Top
#70722 - 2002-10-14 09:44 PM Re: su.exe question
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Just specify the executable in the Task Scheduler Wizard. Alternatively, use the ScheduleTask () UDF.

And take a look at W2k/XP - Keep the Window visible on login?
_________________________
There are two types of vessels, submarines and targets.

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 895 anonymous users online.
Newest Members
batdk82, StuTheCoder, M_Moore, BeeEm, min_seow
17885 Registered Users

Generated in 0.069 seconds in which 0.026 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