Page 1 of 1 1
Topic Options
#37540 - 2003-03-07 03:21 PM scheduletask() error with 'Interactive'...
Rocco Capra Offline
Hey THIS is FUN
*****

Registered: 2002-04-01
Posts: 380
Loc: Mansfield Ohio
All (or Jens),

I try to use the 'Interactive' option on JT.exe and get the following output...
code:
[ Setting Task Scheduler Job ]
[TRACE] Created trigger 0
[TRACE] Setting account information
[TRACE] Setting job's properties
[ERROR] Expected job property name but found token 'Interactive'
[TRACE] Setting target computer to '\\MAN07536'
[TRACE] Adding job 'VNC_Mess.job'
[TRACE] Activating job 'VNC_Mess.job'
0
The operation completed successfully.

...and the job is not there.

Here is the code...
code:
$taskname='VNC_Mess.job'
$computer=$COMPUTER
$date='TODAY'
$time='$RUNTIME'
$type='ONCE'
$userid='taskadmin'
$userpw='password'
$comment='This task is to Show VNC Dissconnect Message.'
$command='%WINDIR%\mess.exe' ;crypted kix script
$parameters=''
scheduletask($taskname,$computer,$date,$time,$type,$userid,
$userpw,$comment,$command,$parameters)
? @SERROR
:END
GET $_
QUIT
;==========================================================
;==========================================================
FUNCTION scheduletask($taskname, $computer, $date, $time, $type, $userid,
$userpw, $comment, $command, $parameters)
DIM $jtexe, $shellcmd, $retcode
IF $taskname=''
? 'Variable TASKNAME in function SCHEDULETASK is empty'
; EXIT 87
ENDIF
IF $computer=''
? 'Variable COMPUTER in function SCHEDULETASK is empty'
; EXIT 87
ENDIF
IF $date=''
? 'Variable DATE in function SCHEDULETASK is empty'
; EXIT 87
ENDIF
IF $time=''
? 'Variable TIME in function SCHEDULETASK is empty'
; EXIT 87
ENDIF
IF $type=''
? 'Variable TYPE in function SCHEDULETASK is empty'
; EXIT 87
ENDIF
IF $userid=''
? 'Variable USERID in function SCHEDULETASK is empty'
; EXIT 87
ENDIF
IF $userpw=''
; ? 'Variable USERPW in function SCHEDULETASK is empty'
; EXIT 87
ENDIF
IF $comment=''
? 'Variable COMMENT in function SCHEDULETASK is empty'
; EXIT 87
ENDIF
IF $command=''
? 'Variable COMMAND in function SCHEDULETASK is empty'
; EXIT 87
ENDIF
IF not vartype($parameters)
DIM $parameters
$parameters=''
ENDIF
; this should point to your copy of jt.exe
$jtexe='%WINDIR%\jt.exe'
; delete a potentially existing task
$shellcmd=$jtexe+' /SM \\'+$computer+' /SD '+$taskname
SHELL '%COMSPEC% /e:1024 /c '+$shellcmd+" >NUL"
; IF @ERROR > 0
; $RC = Open(2,"\\MANFP1NT\Public\IT\_RoccoC\temp\log-off_nt.txt",5)
; $RC = WriteLine(2,@SERROR+@CRLF+@ERROR+@CRLF)
; $RC = Close(2)
; ENDIF

; create a new task, save it, and force a run
$shellcmd = $jtexe
$shellcmd = $shellcmd+ ' /CTJ StartDate='+$date
$shellcmd = $shellcmd+ ' StartTime='+$time
$shellcmd = $shellcmd+ ' HasEndDate=0'
$shellcmd = $shellcmd+ ' KillAtDuration=0'
$shellcmd = $shellcmd+ ' Disabled=0'
$shellcmd = $shellcmd+ ' Type='+$type
$shellcmd = $shellcmd+ ' /SC '+$userid+' '+$userpw
$shellcmd = $shellcmd+ ' /SJ ApplicationName="'+$command+'"'
$shellcmd = $shellcmd+ ' Parameters="'+$parameters+'"'
$shellcmd = $shellcmd+ ' WorkingDirectory="%WINDIR%"'
$shellcmd = $shellcmd+ ' Comment="'+$comment+'"'
$shellcmd = $shellcmd+ ' Creator="'+@USERID+'"'
$shellcmd = $shellcmd+ ' Priority=Normal'
$shellcmd = $shellcmd+ ' Interactive=1'
$shellcmd = $shellcmd+ ' MaxRunTime=3600000'
$shellcmd = $shellcmd+ ' DontStartIfOnBatteries=0'
$shellcmd = $shellcmd+ ' KillIfGoingOnBatteries=0'
$shellcmd = $shellcmd+ ' RunOnlyIfLoggedOn=0'
$shellcmd = $shellcmd+ ' SystemRequired=0'
$shellcmd = $shellcmd+ ' DeleteWhenDone=1'
$shellcmd = $shellcmd+ ' Suspend=0'
$shellcmd = $shellcmd+ ' StartOnlyIfIdle=0'
$shellcmd = $shellcmd+ ' KillOnIdleEnd=0'
$shellcmd = $shellcmd+ ' RestartOnIdleResume=0'
$shellcmd = $shellcmd+ ' Hidden=0'
$shellcmd = $shellcmd+ ' TaskFlags=0'
$shellcmd = $shellcmd+ ' /SM \\'+$computer
$shellcmd = $shellcmd+ ' /SAJ '+$taskname
$shellcmd = $shellcmd+ ' /SAC '+$taskname
SHELL "%COMSPEC% /e:1024 /c "+$shellcmd+" "
$scheduletask=@ERROR
ENDFUNCTION

If I don't use the 'Interactive' option the job gets pushed like it should, but problem is the 'MessageBox' doesn't display to the logged on user. It is running in the process window under the taskadmin account.

I guess the real question would be what do I need to do to get the logged on user to see that message box?

Here is the simple code for the mess.exe...
code:
BREAK ON 
$RC=MessageBox('The HelpDesk Technician has disconnected from your PC.'+@CRLF+
'Do you want to view the log file "C:\WinVNC_log.txt" ?',
@WKSTA,68)
IF(@ERROR='6') RUN 'NotePad.exe "C:\WinVNC_log.txt"' ENDIF
;[ 6 = YES ] [ 7 = NO ]
QUIT

TIA,
Rocco
_________________________
I Love this board!! -------------------- My DEV PC is running KIX 4.22 WINXP Pro

Top
#37541 - 2003-03-07 03:42 PM Re: scheduletask() error with 'Interactive'...
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
Why not just start a new process through WMI? That process would run under the account of the currenly logged-in user and the user will be able to interact with it. Alternatively, use the SENDMESSAGE() function to send a message to the user.

The 'startign remote procees' has been discussed numerous times already, please use the KiXtart BBS Search to retrieve the relevant threads.
_________________________
There are two types of vessels, submarines and targets.

Top
#37542 - 2003-03-07 03:55 PM Re: scheduletask() error with 'Interactive'...
Rocco Capra Offline
Hey THIS is FUN
*****

Registered: 2002-04-01
Posts: 380
Loc: Mansfield Ohio
I've already done a search, but nothing answered my question. [Frown] So I had to ask.

SendMessage is easy, that works great, but I need to make it as simple as can be for the user. If I tell them where to find the log they never will. [Roll Eyes] If I give them a button to click to open the log, they will.

I don't know how to use the WMI stuff to well, can you give me a place to start? [Confused]

Also, as a side note at this point, have you ever used the 'Interactive' option sucessfully?

Thanks,
Rocco
_________________________
I Love this board!! -------------------- My DEV PC is running KIX 4.22 WINXP Pro

Top
#37543 - 2003-03-07 04:08 PM Re: scheduletask() error with 'Interactive'...
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
I don't want my users to 'interact' with my scripts [Wink] also, AFAIK, the 'interactive' is with regards to the user accoun the task run under.

See WMIKill() - stops a process amd modify to start a porcess.
_________________________
There are two types of vessels, submarines and targets.

Top
#37544 - 2003-03-07 05:07 PM Re: scheduletask() error with 'Interactive'...
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Interactive (in the old scheduler at least) meant that it would "appear" on the console if a user logged in.

This is vital for things like ntbackup, as if this gets stuck for any reason - no tape in drive for example - it will just hang with a prompt. The next night it will fail to start because there is already a hung process running.

If you don't use the interactive switch it remains stuck in the background with no clue about what is going on.

Top
#37545 - 2003-03-07 05:41 PM Re: scheduletask() error with 'Interactive'...
Rocco Capra Offline
Hey THIS is FUN
*****

Registered: 2002-04-01
Posts: 380
Loc: Mansfield Ohio
Ok Jens,

Ive looked at those UDF's as well as MSDN (dowloaded the wmi tutorial) and am more lost than ever! [Embarrassed]

What do I do with this to get it to work?...
code:
$COMPUTER='MAN07536'
$objWMIService=GetObject('winmgmts:{impersonationLevel=impersonate}!//'+$COMPUTER)
$RC=$objWMIService.Create("notepad.exe", null, null, intProcessID) ;+'\root\cimv2:Win32_Process'

[Frown]

Rocco
_________________________
I Love this board!! -------------------- My DEV PC is running KIX 4.22 WINXP Pro

Top
#37546 - 2003-03-07 05:45 PM Re: scheduletask() error with 'Interactive'...
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
Nearly there:
code:
$COMPUTER=@WKSTA

$objWMIService=GetObject('winmgmts:{impersonationLevel=impersonate}!//'+$COMPUTER+'\root\cimv2:Win32_Process')
? ''+@ERROR+' - '+@SERROR

$RC=$objWMIService.Create('notepad.exe')
? ''+@ERROR+' - '+@SERROR

_________________________
There are two types of vessels, submarines and targets.

Top
#37547 - 2003-03-07 05:57 PM Re: scheduletask() error with 'Interactive'...
Rocco Capra Offline
Hey THIS is FUN
*****

Registered: 2002-04-01
Posts: 380
Loc: Mansfield Ohio
Thank you,
thank you very much.
_________________________
I Love this board!! -------------------- My DEV PC is running KIX 4.22 WINXP Pro

Top
#37548 - 2003-03-07 06:04 PM Re: scheduletask() error with 'Interactive'...
Rocco Capra Offline
Hey THIS is FUN
*****

Registered: 2002-04-01
Posts: 380
Loc: Mansfield Ohio
UUUhhhhhhgggggg.

It works for $COMPUTER=@WKSTA but not for remote PC. [Frown]

The remote PC is WIN2000 The kill proccess works but not starting.

I get "0's" for return codes but nothing happens on the remote PC at all.

code:
$COMPUTER'MAN07536'
?"$COMPUTER"
$objWMIService=GetObject('winmgmts:{impersonationLevel=impersonate}!//'+$COMPUTER+'\root\cimv2:Win32_Process')
? ''+@ERROR+' - '+@SERROR

$RC=$objWMIService.Create('%WINDIR%\mess.exe')
? ''+@ERROR+' - '+@SERROR



[ 07. March 2003, 18:06: Message edited by: Rocco Capra ]
_________________________
I Love this board!! -------------------- My DEV PC is running KIX 4.22 WINXP Pro

Top
#37549 - 2003-03-07 06:09 PM Re: scheduletask() error with 'Interactive'...
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
well, at least windir should be different...
$RC=$objWMIService.Create('%%WINDIR%%\mess.exe')

should do little difference.
_________________________
!

download KiXnet

Top
#37550 - 2003-03-07 06:13 PM Re: scheduletask() error with 'Interactive'...
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
Search the BBS for 'Win32_Process'. you'll find threads like this:

remote execution .

Also, there seems to be a change in the security model for Windows XP with regards to remote execution of scripts and having the user interact with this. However, don't have a source URL for this.
_________________________
There are two types of vessels, submarines and targets.

Top
#37551 - 2003-03-07 06:13 PM Re: scheduletask() error with 'Interactive'...
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Which %windir% would expand? Would it be the windir of the local or remote?
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#37552 - 2003-03-07 06:15 PM Re: scheduletask() error with 'Interactive'...
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
good question les [Razz]
_________________________
!

download KiXnet

Top
#37553 - 2003-03-07 06:34 PM Re: scheduletask() error with 'Interactive'...
Rocco Capra Offline
Hey THIS is FUN
*****

Registered: 2002-04-01
Posts: 380
Loc: Mansfield Ohio
Well,

this works...
code:
$COMPUTER='MAN07536'
?"$COMPUTER"
$objWMIService=GetObject('winmgmts:{impersonationLevel=impersonate}!//'
+$COMPUTER+'\root\cimv2:Win32_Process')
? ''+@ERROR+' - '+@SERROR

$RC=$objWMIService.Create('mess.exe')
? ''+@ERROR+' - '+@SERROR
?'end'
GET $_

But is still not visable to the user.
_________________________
I Love this board!! -------------------- My DEV PC is running KIX 4.22 WINXP Pro

Top
#37554 - 2003-03-07 06:44 PM Re: scheduletask() error with 'Interactive'...
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
sure [Big Grin]
from msdn:
quote:
The Create WMI class method creates a new process. A fully-qualified path needs to be specified in cases where the program to be launched is not in the search path of Winmgmt.exe. If the newly created process attempts to interact with objects on the target system without appropriate access privileges, it is terminated without notification to this method.

For security reasons the Win32_Process.Create method cannot be used to start an interactive process.



[ 07. March 2003, 19:32: Message edited by: Lonkero ]
_________________________
!

download KiXnet

Top
#37555 - 2003-03-07 07:06 PM Re: scheduletask() error with 'Interactive'...
Rocco Capra Offline
Hey THIS is FUN
*****

Registered: 2002-04-01
Posts: 380
Loc: Mansfield Ohio
"For security reasons the Win32_Process.Create method cannot be used to start an interactive process."

Damn!!

[Mad]
_________________________
I Love this board!! -------------------- My DEV PC is running KIX 4.22 WINXP Pro

Top
#37556 - 2003-03-07 09:09 PM Re: scheduletask() error with 'Interactive'...
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
FYI - in the work I've done with JT.Exe, the INTERACTIVE and HaltOnError boolean values do not seem to be implemented within JT. JT error-exits when those parameters are supplied. I can't even get it to TRY and use those params.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#37557 - 2003-08-15 01:27 PM Re: scheduletask() error with 'Interactive'...
Breaker Offline
Hey THIS is FUN
*****

Registered: 2001-06-15
Posts: 268
Loc: Yorkshire, England
Sorry to flog this old horse again - I take it that since this point no-one else has had any luck using the Interactive property within JT.exe?

Just checkin'...

[ 15. August 2003, 13:27: Message edited by: Breaker ]
_________________________
================================================
Breaker


Top
#37558 - 2003-08-15 01:36 PM Re: scheduletask() error with 'Interactive'...
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
one could always use the RPC bug to run code without admin privs! [Big Grin]
_________________________
!

download KiXnet

Top
#37559 - 2003-08-15 02:55 PM Re: scheduletask() error with 'Interactive'...
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
Breaker:

The 'Interactive' and 'HaltOnError' options simple do not work. I've also never encountered a situation where I would need an interactive sessions. The beauty of the Task Scheduler, in my mind, is that it completely hides the scripts that I run under administrative accounts.
_________________________
There are two types of vessels, submarines and targets.

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
2 registered (morganw, mole) and 414 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

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