Page 2 of 4 <1234>
Topic Options
#190231 - 08/10/21 10:31 PM Re: Hi, All - (Where do i Post a Full Script I want to Share) [Re: Glenn Barnas]
Indigo Offline
Fresh Scripter
**

Registered: 08/10/01
Posts: 34
In the example below when I am setting up the variables to be passed do I have to demention the variables again if the Var names are the same as previously Dim'ed Variables.

For Example $EmailServer, or $IT_Email

 Code:
Function SendEmail($User,$system,$systemup,$EmailServer,$IT_Email,$EmailSufix,$RS_Logs,$Userstoskip)
; == Declaring Variables
Dim $User			; User to be emailed
Dim $System			; Hostname of current system
Dim $Systemup		; Uptime of Current system
Dim $Unli			; Defined as (User Not Logged In) - Incase user isn't logged in

;Dim $EmailSufix 	; Global and needs to be passed.
;Dim $IT_Email 		; is Global and needs to be passed.
;Dim $RS_log		; is Global and needs to be passed.


If len(ltrim($User)) <> 0	; == This checks to make sure that a 0 digit value didn't show up for $User
	If checkusers($User,$Userstoskip) = -1
		;Shell 'bmail -s $EmailServer -t $User@@$EmailSufix -f $IT_Email -a "(System Reboot Needed!) Uptime: $systemup Days." -m $RS_Logs\$system.SentEmail.txt'
	Else
		;Shell 'bmail -s $EmailServer -t $IT_Email -f $IT_Email -a "$system - $user Uptime: $systemup Days." -m $RS_Logs\$system.SentEmail.txt'
		;Shell '%compsec% net send \\$system "Alert Notice: This system has been turned on for $systemup days please reboot!, Thanks IT"'
	Endif
Else
	$Unli = "(User Not Logged In)"
	Shell 'bmail -s $EmailServer -t $IT_Email -f $IT_Email -a "$system - $Unli System Reboot Needed! It Has been Turned on for $systemup Days." -m $RS_Logs\$system.SentEmail.txt'
	;Shell '%compsec% net send \\$system "Alert Notice: This system has been turned on for $systemup days please reboot!, Thanks IT"'
Endif
EndFunction



Also When I call a second Function inside of the first one like below for Checkusers do I have to pass the $Userstoskip Variable to the Function SendEmail First and then to the Function checkusers for it to pass the information along or can I just call checkusers with he added $Userstoskip variable and it will work fine.


 Code:
If checkusers($User,$Userstoskip) = -1
		;Shell 'bmail -s $EmailServer -t $User@@$EmailSufix -f $IT_Email -a "(System Reboot Needed!) Uptime: $systemup Days." -m $RS_Logs\$system.SentEmail.txt'
	Else
		;Shell 'bmail -s $EmailServer -t $IT_Email -f $IT_Email -a "$system - $user Uptime: $systemup Days." -m $RS_Logs\$system.SentEmail.txt'
		;Shell '%compsec% net send \\$system "Alert Notice: This system has been turned on for $systemup days please reboot!, Thanks IT"'
	Endif
Else
	$Unli = "(User Not Logged In)"
	Shell 'bmail -s $EmailServer -t $IT_Email -f $IT_Email -a "$system - $Unli System Reboot Needed! It Has been Turned on for $systemup Days." -m $RS_Logs\$system.SentEmail.txt'
	;Shell '%compsec% net send \\$system "Alert Notice: This system has been turned on for $systemup days please reboot!, Thanks IT"'
Endif


Thanks!

Indigo


Edited by Indigo (08/10/21 10:33 PM)

Top
#190232 - 08/10/21 10:52 PM Re: Hi, All - (Where do i Post a Full Script I want to Share) [Re: Indigo]
Glenn Barnas Moderator Offline
KiX Supporter
*****

Registered: 03/01/28
Posts: 4196
Loc: New Jersey
The environment of a function is unique - the variable $User defined in the main program as a local will not be visible in the function. Thus, if you don't define it in the function, you'll get an undeclared var error when Explicit is enabled. You need to define the vars in the functions, too.

That's why I add the "_" to my function var names - just to reinforce that they are unique to the function. It also protects against corruption due to variable reuse if Explicit is off.

As far as passing vars to a function, you need to pass everything that the function will need. Remember that the function gets a copy of the data, not the actual data, so you can't just modify the data in a function the way you can in a subroutine. (Subroutines are in the same memory context as the main program.) So, in your example, you'd need to pass EMailServer, IT_Email, System, etc..

Glenn
_________________________

Actually I am a Rocket Scientist! \:D

Top
#190246 - 08/10/22 05:57 PM Re: Hi, All - (Where do i Post a Full Script I want to Share) [Re: Glenn Barnas]
Indigo Offline
Fresh Scripter
**

Registered: 08/10/01
Posts: 34
I am cose to having Version .2 done. I have made most your suggested changes.

I however, can't run explisit on because I would have to debug every line of code that is brought into my script for accuracy.

I have cleaned up the display output, functions, and removed duplicate code.

the last thing I am tiding up is he email funcion. I will more than likely be adding your suggestion to the $CMD variable to create the emailing funciton.

Thanks for all the help!


Edited by Indigo (08/10/22 08:59 PM)

Top
#190248 - 08/10/22 08:06 PM Re: Hi, All - (Where do i Post a Full Script I want to Share) [Re: Indigo]
Indigo Offline
Fresh Scripter
**

Registered: 08/10/01
Posts: 34
YAY!!! V.2 is finished! haha \:\) I am a Tad Pumped about it. Looks cleaner, and Seemingly runs smoother.

I only 2 options disabled at the moment.
Auto Rebooting:
 Code:
If Exist ($RS_Logs + "\" + $Computer + ".SentEmail.txt")
    @CRLF + $Computer + " Is being rebooted.." + @CRLF
    ;Shutdown ($computer, "Please Save Your Work,  This System Is Being Rebooted in 1 min.",60,1,1)
Else


This Section Below Sends a Net Send Message to the Machine when a users isn't logged in, so the next time they log in they will get a Net Send message telling them to reboot.

 Code:
If checkusers($_User,$_Userstoskip) = -1		; Makes sure certian users don't get emails.
	Shell $_Email
Else
	; ***** Shell '%compsec% net send \\$_System "Alert Notice: This system has been turned on for $systemup days please reboot!, Thanks IT"'
Endif


To Get both of these options working you need to UnComment them.

Well with no Further Adue Here is V.2 \:\)

 Code:
; ===========================================================================================
;
;	Title:   Windows XP Reboot of network clients
;	Author:  Indigo			
;	Description:  Sends out emails at 7 Days, and Reboots at 10	
;	Version: .2
;
; ===========================================================================================

; == Seting Kixtart Options == 

$Rc = SetOption('Explicit', 'Off')
$Rc = SetOption('NoVarsInStrings', 'On')
$Rc = SetOption('NoMacrosInStrings', 'On')
$Rc = SetOption('WrapAtEOL', 'On')

Break on

; == Declaring Variables. == 

Dim $DontReboot		; == Systems that won't be rebooted
Dim $UserstoSkip	; == Users that will be skipped
Dim $EmailServer	; == The Hostname of the Email Server
Dim $EmailSufix		; == The "company.com" in the Email addresses
Dim $RS_Logs		; == The Log Location \\server\share\path\
Dim $IT_Email		; == The Administrator Email
Dim $Rc			; == Return Code for Kixtart Options
Dim $Computers		; == An Array that holds all the Computers Comnetview gathers
Dim $Computer		; == Each Compuer in Computers
Dim $Online		; == Systems Online / Not Online
Dim $Winver		; == Windows Version
Dim $WMICheck		; == WmiCheck pass/fail
Dim $Uptime		; == Uptime in Days IE. 10
Dim $Kixlib		; == Kix Library location

; == Kixlib Defined ==
$Kixlib = "\\Server\Share\Path"						; Define Where your Kixtart Lib is here Do not place a trailing \
; === Includes all Udfs needed for this script ===

 Call $Kixlib + "\Comnetview.udf"
 Call $Kixlib + "\WmiUptime.udf"
 Call $Kixlib + "\Translatename.udf"
 Call $Kixlib + "\Ping.udf"
 Call $Kixlib + "\FnWMIloggedin.udf"
 Call $Kixlib + "\WMIConfirm.udf"

; == Intializing  Computer & User Special Consideration Veriables ==  ***** Variables below must be changed to needed Values ******

$DontReboot  = "Computer Name Here" , "Computer Name Here"		; Computers to Be Skipped
$Userstoskip = "User Name Here","User Name Here"			; Users to be Skipped
$EmailServer = "Email Server Host Name" 				; HostName of Email Server
$EmailSufix  = "Email Suffix"						; Sufix of Email Address Company.com

$RS_Logs = "\\server\share\path" 					; Don't use the trailing \ because it won't work right
$IT_Email = "Admin@company.com"       					; Email Address of System Admin or Group

; == Clears Log Files If Script has been run before == 		       **********************************************************

del $RS_Logs + "\Systems_UpTime.txt"							
del $RS_Logs + "\Systems_Offline.txt"		

$computers = COMNetView()						; == Locates computers on the network 
CLS
For Each $computer in $computers											
	
	$online = Ping($computer,0,0,1)	; == Ping confirms computer online
	If $online = "1"														
		$winver = ReadValue("\\" + $computer + "\HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion","ProductName")
		If $winver = "Microsoft Windows XP" 								
			$WMICheck = WMIConfirm($computer)
				If $WMICheck <> 0										
					$UpTime = WMIuptime($computer)
					$Userloggedin = GetloginName($Computer)	
					
					; == Displays Current System Information
					CLS
					"System: " + $Computer +" (Online)" + @CRLF
					"OS: (" $Winver ")" + @CRLF
					"User: " + $Userloggedin + @CRLF
					"Uptime: " + $Uptime[0] + " Days" + @CRLF
					; --------------------------------------					
					
					If len(ltrim($Uptime[0])) <> 0					; == Checks digit value of Uptime to see if it is 0 

or not
						If Systemcheck($Computer,$DontReboot) = -1		; == Checks to make sure system isn't in the 

Protected list
							
							If $Uptime[0] >= 7
								If RedirectOutput ($RS_Logs + "\Systems_UpTime.txt") = 0 
									$Userloggedin = GetloginName($computer)	
									? $computer + "'s Uptime is: " + $Uptime[0] + " Days.  " + $Userloggedin ?
									$ = RedirectOutput("")
								EndIf 
							EndIf;
					
							Select
								Case $Uptime[0] >= 0 and $Uptime[0] < 7								

			
							
									If Exist ($RS_Logs + "\" + $computer + ".SentEmail.txt")
										"Email Tag File found Deleting .... < 7 " + @CRLF
										del $RS_Logs + "\"+ $computer + ".SentEmail.txt"
									Endif
									@CRLF
									
								Case $Uptime[0] >= 7 and $UpTime[0] < 10
									
									"System is being processed." + @CRLF
									WriteEmail($computer,$Uptime[0],$RS_Logs)
									

SendEmail($Userloggedin,$Computer,$Uptime[0],$EmailServer,$IT_Email,$EmailSufix,$RS_Logs,$Userstoskip,0)
									"Writing Log File, and Sending Email >= 7 And < 10 " + @CRLF
									
								Case $Uptime[0] >= 10 										
									
									If Exist ($RS_Logs + "\" + $Computer + ".SentEmail.txt")
										@CRLF + $Computer + " Is being rebooted.." + @CRLF
										;Shutdown ($computer, "Please Save Your Work,  This System Is Being Rebooted 

in 1 min.",60,1,1)
									Else
										"Writing Log File, and Sending Email >= 10 " + @CRLF
										WriteEmail($computer,$Uptime[0],$RS_Logs)
										

SendEmail($Userloggedin,$Computer,$Uptime[0],$EmailServer,$IT_Email,$EmailSufix,$RS_Logs,$Userstoskip,0)
									Endif
							
							Endselect
						Else
							@CRLF + "System Is In The Protected List..(Skipping)" + @CRLF
						EndIf
					Else
					@CRLF +  "Uptime Check Failed!!! (Skipping & Logging)" + @CRLF + "Logfile: " + $RS_Logs + 

"\System_UptimeChck_Failed.txt" + @CRLF
						If RedirectOutput ($RS_Logs + "\System_UptimeChck_Failed.txt") = 0 
							"Uptime on: " + $computer + " Failed!!" + @CRLF
							$ = RedirectOutput("")
						EndIf
					EndIf
				Else
					$computer + " was skipped & Logged for review. WmiReturn Code: " + $WMICheck + @CRLF
					If RedirectOutput ($RS_Logs + "\Errorlog.txt") = 0 
						$computer + "'s Error Code is " + @error + " - " + @SERROR + @CRLF
						"This system was skipped & Logged for review. WmiReturn Code: " + $WMICheck + @CRLF
						$ = RedirectOutput("")
					EndIf 
				Endif
		EndIf
	Else
		If RedirectOutput ($RS_Logs + "\Systems_Offline.txt") = 0 
			$computer ?
			$ = RedirectOutput("")
		EndIf
	Endif
Next
; ----- System Reboot Email with attached System Uptimes Log -----
	
	SendEmail($Userloggedin,$Computer,$Uptime[0],$EmailServer,$IT_Email,$EmailSufix,$RS_Logs,$Userstoskip,1)

; ================== Functions Below This Point ====================

;----- This function just checks to make sure we don't reboot a pc that needs to stay up. --
Function Systemcheck($_Chkcomputer,$_DontReboot)		

; == Declaring Variables
Dim $_Result		; Holds the Result of the calculation
Dim $_Chkcomputer	; Computer to be checked
Dim $_DontReboot 	; Global Variable Transfered to Function.

	$_Result = 0
	$_Chkcomputer = TRIM(LCASE($_Chkcomputer))					
	$_Result = Ascan($_DontReboot,$_Chkcomputer,0)				
	$Systemcheck = $_Result										

EndFunction

; ---- Removes invalid email users ----
Function checkusers($_Users,$_Userstoskip)		

; == Declaring Variables
Dim $_Result		; Holds the Result of the calculation
Dim $_Chkuser		; User to be checked
Dim $_Users		; User passed to function (raw)
Dim $_Userstoskip 	; Global Variable Transfered to Function.

	$_Result = 0
	$_Chkuser = TRIM(LCASE($_Users))					
	$_Result = Ascan($_Userstoskip,$_Users,0)				
	$Checkusers = $_Result										

EndFunction

;----- Pulls in the user that is logged into X machine  ----------------------------
Function GetloginName($_Chkcomputers)

; == Declaring Variables
Dim $_Usrloggedin	; User Logged into current system in current format Domain\Username
Dim $_Username		; Just username by itself

	$_Usrloggedin = fnWMILoggedin (1,$_Chkcomputers)			; == Current user logged in. Remove ' ' around $_Chkcomputers may be needed
	$_Usrname = substr ($_Usrloggedin,6)					; == Removes "Domain\" Domain.  May need to look into a different way to 

shorten

If len(ltrim($_Usrloggedin)) = 0	; == Checks for a 0 digit value assigned to user, if it did (User not logged) in is Returned.
	$_Unli = "(User Not Logged In)"
	$Getloginname = $_Unli
	Return
Endif

$Getloginname = $_Usrname

EndFunction


;----- Sends an email to the user whos system has been up for more than 7 days, and sends email to administrator.
Function SendEmail($_User,$_System,$_Systemup,$_EmailServer,$_IT_Email,$_EmailSufix,$_RS_Logs,$_Userstoskip,$_AdminEmail)
; == Declaring Variables
Dim $_User		; User to be emailed
Dim $_System		; Hostname of current system
Dim $_Systemup		; Uptime of Current system
Dim $_Unli		; Defined as (User Not Logged In) - Incase user isn't logged in
Dim $_EmailSufix 	; Global Variable Transfered to Function.
Dim $_IT_Email 		; Global Variable Transfered to Function.
Dim $_RS_log		; Global Variable Transfered to Function.
Dim $_Email		; Building Block Variable for Sending Emails.

			; Through a Variable for On/Off maybe setup a Debug Admin Feature, so only admin is emailed

$_Email = 'bmail'
$_Email = $_Email + ' -s '
$_Email = $_Email + $_EmailServer
$_Email = $_Email + ' -f ' + $_IT_Email	
	
	If $_AdminEmail = 1
		$_Email = $_Email + ' -t ' + $_IT_Email
		$_Email = $_Email + ' -a ' + '"Systems That need to be rebooted"'
		$_Email = $_Email + ' -m ' + $_RS_Logs + '\Systems_uptime.txt'
	Else
		$_Email = $_Email + ' -t ' + $_IT_Email		; Change this back t $_User so it sends the email to the user.
		$_Email = $_Email + ' -a ' + '"(System Reboot Needed!) Uptime: ' + $_Systemup + ' Days."'
		$_Email = $_Email + ' -m ' + $_RS_Logs + '\' + $_System + '.SentEmail.txt'
	EndIf

If checkusers($_User,$_Userstoskip) = -1		; Makes sure certian users don't get emails.
	Shell $_Email
Else
	;Shell '%compsec% net send \\$_System "Alert Notice: This system has been turned on for $systemup days please reboot!, Thanks IT"'
Endif

EndFunction


;----- Writes the email file that is included in the body of the email sent. ------------
Function WriteEmail($_Computer,$_Uptime,$_RS_Logs)

; == Declaring Variables
Dim $_Computer 		; Hostname of Current System
Dim $_Uptime		; Uptime of Current System
Dim $_RS_Logs		; Handles Log locations

	If RedirectOutput ($_RS_Logs + "\"+ $_Computer + ".SentEmail.txt",1) = 0  ; == Creates a Log File to indicate the sending of an email.
		@CRLF $_Computer + "'s Uptime is: " + $_Uptime + " Days."	
		@CRLF
		@CRLF "This is the Body of the Email that will be sent... Fill it in with whatever you want."
		@CRLF
		$ = RedirectOutput("")
	EndIf 

EndFunction

Top
#190249 - 08/10/22 09:12 PM Re: Hi, All - (Where do i Post a Full Script I want to Share) [Re: Indigo]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 01/06/05
Posts: 22294
Loc: Claremore, OK
LOL.
I rock. (long line police mantra)
_________________________
!

download KiXnet

Top
#190251 - 08/10/22 09:16 PM Re: Hi, All - (Where do i Post a Full Script I want to Share) [Re: Lonkero]
Indigo Offline
Fresh Scripter
**

Registered: 08/10/01
Posts: 34
hehe yeah,

Some of those Functions i call have a crap load of variables being passed.

Top
#190252 - 08/10/22 09:20 PM Re: Hi, All - (Where do i Post a Full Script I want to Share) [Re: Indigo]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 01/06/05
Posts: 22294
Loc: Claremore, OK
that wouldn't be a problem if you lonkenized your code. :p

for the newbies, who don't know what that means, kixtart dictionary reference is required.
 Quote:

lon·ke·nize
–verb (used with object)
1. to compress and to cryptify source code in such a manner by a person, that it's hard for another person to read or comprehende and at the same time minimize the amount of strokes required for the fully functional code.

see also: KiXgolf
_________________________
!

download KiXnet

Top
#190253 - 08/10/22 09:34 PM Re: Hi, All - (Where do i Post a Full Script I want to Share) [Re: Lonkero]
Indigo Offline
Fresh Scripter
**

Registered: 08/10/01
Posts: 34
ahha nice!

I will work on it ;\)

Top
#190262 - 08/10/23 09:16 AM Re: Hi, All - (Where do i Post a Full Script I want to Share) [Re: Indigo]
Mart Moderator Offline
KiX Supporter
*****

Registered: 02/03/27
Posts: 4603
Loc: The Netherlands
 Originally Posted By: Indigo
ahha nice!

I will work on it ;\)


Nooooooooo! \:o
Please do not Lokenize the code. You're messing with everybody’s mind if you do that.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#190274 - 08/10/23 03:10 PM Re: Hi, All - (Where do i Post a Full Script I want to Share) [Re: Mart]
Indigo Offline
Fresh Scripter
**

Registered: 08/10/01
Posts: 34
:).. I am just kidding as well

I did notice that there is a bug in my script. When it edits the user logged in from its raw data.. its a solid calcuation of stip off the prefix info. For example Domain\username. It is set to strip of the exact numbers of my domain name. I don't think everyone has the same numberes, so i wanted to mention that the username won't come back correctly if it isn't properly substringed.

here is the peice of code that will change this.

 Code:
Function GetloginName($_Chkcomputers)

; == Declaring Variables
Dim $_Usrloggedin	; User Logged into current system in current format Domain\Username
Dim $_Username		; Just username by itself

	$_Usrloggedin = fnWMILoggedin (1,$_Chkcomputers)			; == Current user logged in. Remove ' ' around $_Chkcomputers may be needed
	$_Usrname = substr ($_Usrloggedin,6)	   ; ************ Edit the 6 To whater your Domain\ is.	 

shorten

If len(ltrim($_Usrloggedin)) = 0	; == Checks for a 0 digit value assigned to user, if it did (User not logged) in is Returned.
	$_Unli = "(User Not Logged In)"
	$Getloginname = $_Unli
	Return
Endif

$Getloginname = $_Usrname

EndFunction


Top
#190275 - 08/10/23 03:27 PM Re: Hi, All - (Where do i Post a Full Script I want to Share) [Re: Indigo]
Glenn Barnas Moderator Offline
KiX Supporter
*****

Registered: 03/01/28
Posts: 4196
Loc: New Jersey
Good, 'cause I'd have to track you down and beat you into submission with wet noodles if you weren't.

As for your issue above, the output format is DOMAIN\userid, so
$_UserName = Split(fnWMILoggedIn(), '\')[1]

This splits the output of the function into a 2 element array on the "\" char, and stores only the second element into the $_UserName var - no need to know the length of the domain name that way.

Glenn
_________________________

Actually I am a Rocket Scientist! \:D

Top
#190276 - 08/10/23 04:47 PM Re: Hi, All - (Where do i Post a Full Script I want to Share) [Re: Glenn Barnas]
Indigo Offline
Fresh Scripter
**

Registered: 08/10/01
Posts: 34
Wicked Sweet.

I will adjust the code to accomidate for that.

Hey while i am here, i have noticed that i have a limitation to my code.

My email feature only knows who to email when they are logged into the system the script is quering. However, if they are logged out no username is generated and i am unable to email the user of that system. Can you think of an easy way to pull usernames for the email portion?

And i guess that brings up another goood point... if someone is using this script and the logon names don't match their email address names.. the emailing function won't work at all..

Indigo

Top
#190278 - 08/10/23 04:54 PM Re: Hi, All - (Where do i Post a Full Script I want to Share) [Re: Indigo]
Gargoyle Offline
MM club member
*****

Registered: 04/03/09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
YOu can do an AD lookup to retrieve an Email address. Look at the UDF QUERYLDAP().
_________________________
Today is the tomorrow you worried about yesterday.

Top
#190279 - 08/10/23 04:59 PM Re: Hi, All - (Where do i Post a Full Script I want to Share) [Re: Indigo]
Indigo Offline
Fresh Scripter
**

Registered: 08/10/01
Posts: 34
Well,

Glenn that Change you suggested worked Like a Charm!! No need to worry about the length of the user name.

Hey, just as a side note... How does split know to return only the second half of the split string.

I was looking at it.. and it didn't jump out at me?

Top
#190280 - 08/10/23 05:01 PM Re: Hi, All - (Where do i Post a Full Script I want to Share) [Re: Indigo]
Mart Moderator Offline
KiX Supporter
*****

Registered: 02/03/27
Posts: 4603
Loc: The Netherlands
 Originally Posted By: Indigo

....
Hey, just as a side note... How does split know to return only the second half of the split string.

I was looking at it.. and it didn't jump out at me?


That is the [1] part. An array starts at [0] if there is some data in it so [1] is the second element.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#190281 - 08/10/23 05:02 PM Re: Hi, All - (Where do i Post a Full Script I want to Share) [Re: Mart]
Indigo Offline
Fresh Scripter
**

Registered: 08/10/01
Posts: 34
haha Nice!

Go figure \:\)

Thanks Mort

Top
#190282 - 08/10/23 05:07 PM Re: Hi, All - (Where do i Post a Full Script I want to Share) [Re: Indigo]
Indigo Offline
Fresh Scripter
**

Registered: 08/10/01
Posts: 34
I was looking at fnLdapquery, and its a tad confusing.

Lets say a manage to get the email out of AD, i am unclear how i would link this to the machine that the user was logged in at.


OO oOO i think i got it.

I could do a queary to see who the last person was logged into the system. then i could compare it with the current user.. if they matched use that username.

if they didn't use the one the current user logged in.

if no one is logged in I could then use the last user logged into that pc.

\:\)

that sounds like a good plan.


Edited by Indigo (08/10/23 05:08 PM)

Top
#190283 - 08/10/23 05:20 PM Re: Hi, All - (Where do i Post a Full Script I want to Share) [Re: Indigo]
Allen Moderator Offline
KiX Supporter
*****

Registered: 03/04/19
Posts: 4241
Loc: USA
See if this could help with the email addresses
http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Main=25474&Number=188570#Post188570

Top
#190284 - 08/10/23 05:41 PM Re: Hi, All - (Where do i Post a Full Script I want to Share) [Re: Allen]
Indigo Offline
Fresh Scripter
**

Registered: 08/10/01
Posts: 34
I like this idea, it would work great for the users that stayed logged into the system and i was able to pull their user name, but on the flip side i need to figure out how to tie a machine to a user, so when i don't have a user logged into the machine i can still send an email to that user to reboot their system.

I was orginally thinking i could do that by checking who the last person that logged into the system, but i have been digging around, and i don't see any udfs that grab the last user logged in, and are designed to work remotely \:\(

Top
#190286 - 08/10/23 05:45 PM Re: Hi, All - (Where do i Post a Full Script I want to Share) [Re: Indigo]
Kdyer Offline
KiX Supporter
*****

Registered: 01/01/03
Posts: 6241
Loc: Tigard, OR
 Originally Posted By: Indigo

I was orginally thinking i could do that by checking who the last person that logged into the system, but i have been digging around, and i don't see any udfs that grab the last user logged in, and are designed to work remotely \:\(


If memory serves, you can grab the last logged in person from WMI..

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
Page 2 of 4 <1234>


Moderator:  Jochen, Allen, Radimus, Chris S., Glenn Barnas, ShaneEP, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 113 anonymous users online.
Newest Members
schnuggel, h315060, johnnyutah, pmk31, ArserHsieh
17412 Registered Users

Generated in 0.043 seconds in which 0.012 seconds were spent on a total of 14 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org