Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Windows system variables 1

Status
Not open for further replies.

mntlfngrs

Technical User
Apr 13, 2002
36
US
Hi guys,

How do I use Windows system variable (%USERNAME%) in a procomm script? I'm trying to write the name of the user who ran the script (or at least who was logged in to the PC)to the output file of the script.

Thanks for you help.

Adam "Be all and you'll be to end all.
Life can be a real ball.
State of mind!"
 
Hello,

I looked thru the Procomm 4.8 Help Files and there are No System Variables than can determine the Login / User Name of the Person using the Script.

(1) You Could Write a Script that Has a List of Users that can use the Script.. FLISTBOX.

(2) When the User Selects His/Her Name, It would Update an INI File with the Name and Date when the User Executed the Script.

(3) You would Probably also have to Put in a Password File, for the Users passwords.

Just an Idea


Hank
 
You can use the getenv command to read the contents of an environment variable. However, I don't know if this will work for a Windows system variable as well. If you type set in the DOS window and hit enter, does username show up as one of the defined environment variables? If so, then you could use the getenv command to retrieve this information. I don't see username as one of my defined variables, but the machine I am working on right now (Win98) is not set up for user logins.
 
Hello

I am Currently on Win98SE and have to Login when I boot up. From the MS-Dos Prompt, I used the SET Command to View the Enviroment. Login name Does Not Appear.

 
Thanks knob, That worked perfectly! "Be all and you'll be to end all.
Life can be a real ball.
State of mind!"
 
Hello,

Would you Mind Posting what you Came up with ?? What Windows Version are you using and What Version of Procomm ... Any details Welcome..

Thanks Hank
 
Sure, it was too easy.

;***********PROCEEDURE CROUTPUT**********************
proc croutput
fileout = "z:\DCC_Scripts\Dbackupdata\"
substr pdate $date 0 8
strreplace pdate "/" "-"
strcat fileout pdate
strcat fileout "_"
substr ptime $time24 0 8
strreplace ptime ":" ""
strcat fileout ptime
strcat fileout ".txt"
fopen 52 fileout create TEXT
fwrite 52 "This test was run on " 21
fwrite 52 $Date 10
fwrite 52 " at " 4
fwrite 52 $time24 8
fputs 52 ". "
fwrite 52 "Script was run by " 18
getenv "username" luser
fwrite 52 luser 4
fwrite 52 " on " 4
getenv "computername" compname
fwrite 52 compname 8
fputs 52 ". "
endproc
;************END PROCEEDURE CROUTPUT****************


from dos set cmd...

COMPUTERNAME=xxxxxxxx
USERNAME=xxxx

Running win2kpro with Procomm 4.8 ;latest and greatest!!! "Be all and you'll be to end all.
Life can be a real ball.
State of mind!"
 
Hank, are you just logging on to the Windows machine, or logging into an NT domain? That may make the difference between the username environment variable showing up or not (I'm not at my work to check this theory out though).
 
The following env. variables are NOT supported in win 95/98/me...

%UserName%


%OS%


%UserDomain%


%ComputerName%


On win2kpro %username% still exists when only logging into local machine.
"Be all and you'll be to end all.
Life can be a real ball.
State of mind!"
 
Knob,

I'm on a Stand-Alone Laptop Machine. Not connecting to a Network.. Just thought it would be Nice if you had an Office PC where Several Employees used the Same PC and you wanted to Know used the Procomm Script Last. I may have misunderstood the Post.

Thanks for the Reply.

Hank
 
If you don't have the %username% variable get it for another variable like %userprofile% and pull it from there.

Adam "Be all and you'll be to end all.
Life can be a real ball.
State of mind!"
 
Reference: Win98SE with Login and Password

At DOS Prompt:
Set USERNAME=hankm3
Set
USERNAME=hankm3
Exit Dos Prompt
At DOS Prompt
Set
Username does Not Exist.

Edit The Config.sys File
added
Set USERNAME=hankm3

Used Procomm 4.8
string sLogin
getenv "USERNAME" sLogin
usermsg "USER: %s" sLogin
hankm3 appears

But this appears whoever Logs in on this Machine. hankm3 or Guest !

Like I said, Just as a Reference.....
 
Adam,

You may want to be More Plain in what you are attempting to say.

Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top