All,

I have written 2 scripts that when executed, the first will stop 3 specific services on a remote server, the second will start the same services. Problem is, thye work, however users get access denied.

I start off asking for the user to type yes, and enter. The script then shells and executes netsvc.exe from the res kit. NetSvc.exe command line works for me as a Dom Admin. For these two users, they get access denied. No one would ask whats their access level? I have granted them both local admin rights, and even elevated their perms with ntrights.exe.

What does work; a batch script with a single line of SRVMGR.exe \\servername
I have shown them how to stop the services, and how to start. Seems simple eh?

My reason for wanting my script to work, is I use the sendmail function I downloaded from here (Works Great) to let me know if a user has needed to stop / start the services in the middle of the night. I do not need to be paged unless there is some critical issue.

I ask this, does ones access permissions change in any way when Kix shells out?

I know there are some clean up items left in here from experiments, but if anyone has any critiques, I'm always happy to learn a new technique or way to do it [Cool]

*****Here's the code ************************
; **** Gentran Services Startup Script with Verification ****

Break Off
Color w/b
CLS
Dim $sResponse, $sDirection, $sMachNam, $LogFile
$sDirection = "Stop" ; Values accepted are Start and Stop
$sMachNam = "EDIPROD" ; NetBios server Name of Server
$msgSubject="ATTN: GENTRAN Services Changed Status"
$msgBody="Gentran Services on $sMachNam have been $sDirection" + "ed."
$msgRecip="MISNOTIFICATION@@MyDomain.com"

; Sets Window Title
$ = SetTitle ("MyDomain Gentran Services for $sMachNam Script: $sDirection ")

$ = Execute ('"***************************************************************************"?')
$ = Execute ('" @USERID, Are you sure you wish to $sDirection the Gentran Services?"?')
$ = Execute ('" on $sMachNam!"?')
$ = Execute ('" Please type Yes or No followed by Return. This is NOT case sensitive"?')
$ = Execute ('"***************************************************************************"?')
$ = Execute ('" Type Yes and press Enter to continue : "') Gets $sResponse

If $sResponse = "YES" ; Not Case sensitive YES = YeS =yes =yES
$ = Execute ('"@USERID Replied $sResponse to $sDirection the services."?')
$ = Execute ('"Please wait while we process your request..."?')
$ = Execute ('"Now Starting the GENTRANExecutive service..."??')
Shell "C:\WINNT\SYSTEM32\CMD /E:1024 /C " + "netsvc \\$sMachNam GENTRANExecutive /$sDirection"
If @Error = 1 OR @ERROR = 0
Else
If @ERROR = "3"
$ = Execute ('"STOP: Notify the HelpDesk "?')
$ = Execute ('"That you are missing netsvc.exe in your path. "?')
$RC = LogEvent( 0 , 1 , "@USERID $sDirection" + "ed the Gentran Services" , "\\ironhorse" , "MYScripting")
; $RC = LogEvent( 0 , 1 , "@USERID $sDirection the Gentran Services" , \\$sMachNam "MYScripting")
Return
Else
$ = Execute ('"Failed to Stop Service with FCode:@Error "?')
$ = Execute ('"Which means @SERROR"?')
Return
EndIf
EndIf
$ = Execute ('"Now Starting the GENTRANServerCommunications service"?')
Shell "C:\WINNT\SYSTEM32\CMD /E:1024 /C " + "netsvc \\$sMachNam GENTRANServerCommunications /$sDirection"
If @Error = 1 OR @ERROR = 0
Else
$ = Execute ('"Failed to Stop Service with FCode:@Error "?')
$ = Execute ('"Which means @SERROR"?')
EndIf
$ = Execute ('"Now Starting the GENTRANServerMailbox service"?')
Shell "C:\WINNT\SYSTEM32\CMD /E:1024 /C " + "netsvc \\$sMachNam GENTRANServerMailbox /$sDirection"
If @Error = 1 OR @ERROR = 0
Else
$ = Execute ('"Failed to Stop Service with FCode:@Error "?')
$ = Execute ('"Which means @SERROR"?')
EndIf
sendmail($msgSubject, $msgBody, $msgRecip)
; $RC = LogEvent( 0 , 1 , "@USERID $sDirection" + "ed the Gentran Services" , \\$sMachNam , "MYScripting")
Else ;User aborted, or failed to type yes correctly.
$ = Execute ('"@USERID, Replied with $sResponse, which is equal to a NO!"?')
; sendmail($msgSubject, $msgBody, $msgRecip) ; Used to test failed yes prompt
EndIf
Exit 1

;;; ******************** DO NOT EDIT BELOW THIS LINE ******************
;;; ******************** DO NOT EDIT BELOW THIS LINE ******************

Function sendmail($Subject, $Body, $Rec)
;Create Outlook Object
$objOutlook=CreateObject("Outlook.Application")
;Create NewMessage Object
$NewMessage=$objOutlook.CreateItem(0)
;Set Mail Subject
$NewMessage.Subject=$Subject
;Set Mail Body
$NewMessage.Body=$Body
;Add Recipients
$Recip=$NewMessage.Recipients.add($rec)
;If Outlook cannot resolve the recipient, the message will be displayed
If NOT $Recip.resolve
$NewMessage.Display
EndIf
;Send Message
$NewMessage.send
EndFunction
Return
_________________________
Bumped my mouse again, time to reboot Windoze....