Hello,

I have a script here that runs every 5 minutes in scheduled tasks. The
script checks to see if the pc has a certain ip address and if it does it
disables the dhcp client and displays a message. The problem is I have the
task scheduled to run w/ the administrator's credentials. And unless the
administrator is the one signed in to the pc, the dhcp client will disable
but the message box does not display on the screen. It will give the
message beep however. Then the task continually says "running" because it
is waiting for the user to hit "ok", yet the user can not see the message
box.

What am i missing?

Any help will be greatly appreciated.

Re: Script Not Totally Working in Scheduled Tasks by Jason

Jason
Tue Nov 07 13:17:09 CST 2006

You pretty much solved it yourself based on your description of the
problem.
Unlike the RunAs command, when you run a scheduled task as another user
it does not run interactively. Any part of the task that requires user
input will not be displayed. I'd recommend removing any message boxes,
or recode it to use the Popup method instead, so you can at least set a
timeout on the response.

- Jason
Sean Grieco wrote:
> Hello,
>
> I have a script here that runs every 5 minutes in scheduled tasks. The
> script checks to see if the pc has a certain ip address and if it does it
> disables the dhcp client and displays a message. The problem is I have the
> task scheduled to run w/ the administrator's credentials. And unless the
> administrator is the one signed in to the pc, the dhcp client will disable
> but the message box does not display on the screen. It will give the
> message beep however. Then the task continually says "running" because it
> is waiting for the user to hit "ok", yet the user can not see the message
> box.
>
> What am i missing?
>
> Any help will be greatly appreciated.


Re: Script Not Totally Working in Scheduled Tasks by dNagel

dNagel
Tue Nov 07 13:21:25 CST 2006

*/interactive*: Use this parameter to allow the task to interact with
the desktop of the user who is logged on at the time the task runs.

http://support.microsoft.com/kb/313565

D.


Jason wrote:
> You pretty much solved it yourself based on your description of the
> problem.
> Unlike the RunAs command, when you run a scheduled task as another user
> it does not run interactively. Any part of the task that requires user
> input will not be displayed. I'd recommend removing any message boxes,
> or recode it to use the Popup method instead, so you can at least set a
> timeout on the response.
>
> - Jason
> Sean Grieco wrote:
>
>> Hello,
>>
>> I have a script here that runs every 5 minutes in scheduled tasks. The
>> script checks to see if the pc has a certain ip address and if it does it
>> disables the dhcp client and displays a message. The problem is I have the
>> task scheduled to run w/ the administrator's credentials. And unless the
>> administrator is the one signed in to the pc, the dhcp client will disable
>> but the message box does not display on the screen. It will give the
>> message beep however. Then the task continually says "running" because it
>> is waiting for the user to hit "ok", yet the user can not see the message
>> box.
>>
>> What am i missing?
>>
>> Any help will be greatly appreciated.
>>
>
>

Re: Script Not Totally Working in Scheduled Tasks by Sean

Sean
Tue Nov 07 13:23:57 CST 2006

very cool, thanks Jason...any quick site that you know of that explains the
"popup" method as compared to the "msgbox" method?



"Jason" <flajason@gmail.com> wrote in message
news:1162927029.256174.279850@b28g2000cwb.googlegroups.com...
> You pretty much solved it yourself based on your description of the
> problem.
> Unlike the RunAs command, when you run a scheduled task as another user
> it does not run interactively. Any part of the task that requires user
> input will not be displayed. I'd recommend removing any message boxes,
> or recode it to use the Popup method instead, so you can at least set a
> timeout on the response.
>
> - Jason
> Sean Grieco wrote:
>> Hello,
>>
>> I have a script here that runs every 5 minutes in scheduled tasks. The
>> script checks to see if the pc has a certain ip address and if it does it
>> disables the dhcp client and displays a message. The problem is I have
>> the
>> task scheduled to run w/ the administrator's credentials. And unless the
>> administrator is the one signed in to the pc, the dhcp client will
>> disable
>> but the message box does not display on the screen. It will give the
>> message beep however. Then the task continually says "running" because
>> it
>> is waiting for the user to hit "ok", yet the user can not see the message
>> box.
>>
>> What am i missing?
>>
>> Any help will be greatly appreciated.
>



Re: Script Not Totally Working in Scheduled Tasks by Sean

Sean
Tue Nov 07 14:39:45 CST 2006

Ok, so the "interactive" in AT worked nicely, however I do not see anywhere
that I can have it run every 5 minutes, it is just based off daily....

Can I run the AT command to run every 5 minutes or so?



"Jason" <flajason@gmail.com> wrote in message
news:1162927029.256174.279850@b28g2000cwb.googlegroups.com...
> You pretty much solved it yourself based on your description of the
> problem.
> Unlike the RunAs command, when you run a scheduled task as another user
> it does not run interactively. Any part of the task that requires user
> input will not be displayed. I'd recommend removing any message boxes,
> or recode it to use the Popup method instead, so you can at least set a
> timeout on the response.
>
> - Jason
> Sean Grieco wrote:
>> Hello,
>>
>> I have a script here that runs every 5 minutes in scheduled tasks. The
>> script checks to see if the pc has a certain ip address and if it does it
>> disables the dhcp client and displays a message. The problem is I have
>> the
>> task scheduled to run w/ the administrator's credentials. And unless the
>> administrator is the one signed in to the pc, the dhcp client will
>> disable
>> but the message box does not display on the screen. It will give the
>> message beep however. Then the task continually says "running" because
>> it
>> is waiting for the user to hit "ok", yet the user can not see the message
>> box.
>>
>> What am i missing?
>>
>> Any help will be greatly appreciated.
>



Re: Script Not Totally Working in Scheduled Tasks by smoochi3

smoochi3
Tue Nov 07 16:34:49 CST 2006

You can always run the script when windows boots up and then have it
sleep for 5 minutes.

Sean Grieco wrote:
> Ok, so the "interactive" in AT worked nicely, however I do not see anywhere
> that I can have it run every 5 minutes, it is just based off daily....
>
> Can I run the AT command to run every 5 minutes or so?
>
>
>
> "Jason" <flajason@gmail.com> wrote in message
> news:1162927029.256174.279850@b28g2000cwb.googlegroups.com...
> > You pretty much solved it yourself based on your description of the
> > problem.
> > Unlike the RunAs command, when you run a scheduled task as another user
> > it does not run interactively. Any part of the task that requires user
> > input will not be displayed. I'd recommend removing any message boxes,
> > or recode it to use the Popup method instead, so you can at least set a
> > timeout on the response.
> >
> > - Jason
> > Sean Grieco wrote:
> >> Hello,
> >>
> >> I have a script here that runs every 5 minutes in scheduled tasks. The
> >> script checks to see if the pc has a certain ip address and if it does it
> >> disables the dhcp client and displays a message. The problem is I have
> >> the
> >> task scheduled to run w/ the administrator's credentials. And unless the
> >> administrator is the one signed in to the pc, the dhcp client will
> >> disable
> >> but the message box does not display on the screen. It will give the
> >> message beep however. Then the task continually says "running" because
> >> it
> >> is waiting for the user to hit "ok", yet the user can not see the message
> >> box.
> >>
> >> What am i missing?
> >>
> >> Any help will be greatly appreciated.
> >


Re: Script Not Totally Working in Scheduled Tasks by dNagel

dNagel
Tue Nov 07 19:28:17 CST 2006

Sleep steals CPU time and keeps a process open all the time,
can't you just issue another AT command inside the script ?

This script will create a new scheduled job every one minute...

Change the 1/1440 to something more appropriate

for 1 minute - 1/(60*24)
for 5 minute interval use 1/(1440/5)
for 10 minutes use 1/(1440/10)

call this anything.bat that you want to...

It's currently designed to run from the c:\ folder
look for this in the script:
At %v_input% /interactive "c:\%0"


@ECHO off
SETLOCAL
SET v_vbs=%temp%\~tmp.VBS
SET v_cmd=%temp%\~tmp.cmd
ECHO Set oFS=CreateObject("Scripting.FileSystemObject")>%v_vbs%
ECHO tim=FormatDateTime(now+1/1440,vbShortTime)>>%v_vbs%
ECHO oFS.CreateTextFile("%v_cmd%",2).Write "set v_input=">>%v_vbs%
ECHO oFS.OpenTextFile("%v_cmd%",8).Write tim>>%v_vbs%
cscript.exe //nologo %v_vbs%
CALL %v_cmd%
DEL %v_vbs%
DEL %v_cmd%
SET v_input
ENDLOCAL & SET v_input=%v_input%
:: place your actual commands here...
At %v_input% /interactive "c:\%0"

hth,

D.



smoochi3@gmail.com wrote:
> You can always run the script when windows boots up and then have it
> sleep for 5 minutes.
>
> Sean Grieco wrote:
>
>> Ok, so the "interactive" in AT worked nicely, however I do not see anywhere
>> that I can have it run every 5 minutes, it is just based off daily....
>>
>> Can I run the AT command to run every 5 minutes or so?
>>
>>
>>
>> "Jason" <flajason@gmail.com> wrote in message
>> news:1162927029.256174.279850@b28g2000cwb.googlegroups.com...
>>
>>> You pretty much solved it yourself based on your description of the
>>> problem.
>>> Unlike the RunAs command, when you run a scheduled task as another user
>>> it does not run interactively. Any part of the task that requires user
>>> input will not be displayed. I'd recommend removing any message boxes,
>>> or recode it to use the Popup method instead, so you can at least set a
>>> timeout on the response.
>>>
>>> - Jason
>>> Sean Grieco wrote:
>>>
>>>> Hello,
>>>>
>>>> I have a script here that runs every 5 minutes in scheduled tasks. The
>>>> script checks to see if the pc has a certain ip address and if it does it
>>>> disables the dhcp client and displays a message. The problem is I have
>>>> the
>>>> task scheduled to run w/ the administrator's credentials. And unless the
>>>> administrator is the one signed in to the pc, the dhcp client will
>>>> disable
>>>> but the message box does not display on the screen. It will give the
>>>> message beep however. Then the task continually says "running" because
>>>> it
>>>> is waiting for the user to hit "ok", yet the user can not see the message
>>>> box.
>>>>
>>>> What am i missing?
>>>>
>>>> Any help will be greatly appreciated.
>>>>
>
>

Re: Script Not Totally Working in Scheduled Tasks by dNagel

dNagel
Wed Nov 08 00:40:57 CST 2006

Ok, as long as you use a full path to the batch file
when you initially execute it, this will allow you to
run it from anywhere...

The words "use full path" can not be stressed enough.


@ECHO off
SETLOCAL
SET v_vbs=%temp%\~tmp.VBS
SET v_cmd=%temp%\~tmp.cmd
ECHO Set oFS=CreateObject("Scripting.FileSystemObject")>%v_vbs%
ECHO tim=FormatDateTime(now+1/(1440/1),vbShortTime)>>%v_vbs%
ECHO oFS.CreateTextFile("%v_cmd%",2).Write "set v_input=">>%v_vbs%
ECHO oFS.OpenTextFile("%v_cmd%",8).Write tim>>%v_vbs%

cscript.exe //nologo %v_vbs%
CALL %v_cmd%
DEL %v_vbs%
DEL %v_cmd%
SET v_input
ENDLOCAL & SET v_input=%v_input%
At %v_input% /interactive "%0"


Re: Script Not Totally Working in Scheduled Tasks by Sean

Sean
Wed Nov 08 10:10:22 CST 2006

D,

That's a freakin' awesome script, it does the trick. However, I have a few
quick questions.

1. Is there a way that the cmd box does not splash the time?

2. Can it be setup to delete all scheduled tasks first? Right now the way
it is setup if you reboot it keeps the last task there, so when you log back
in you have 2 tasks running, then the next time you have 3, etc.

3. Can these tasks be hidden when created? That way the user does not see
and cannot delete it....


Thanks again, great script!


"dNagel" <NOTGrandNagel@NotMail.com> wrote in message
news:%239t9PVtAHHA.4292@TK2MSFTNGP02.phx.gbl...
> Sleep steals CPU time and keeps a process open all the time,
> can't you just issue another AT command inside the script ?
>
> This script will create a new scheduled job every one minute...
> Change the 1/1440 to something more appropriate
>
> for 1 minute - 1/(60*24)
> for 5 minute interval use 1/(1440/5)
> for 10 minutes use 1/(1440/10)
>
> call this anything.bat that you want to...
>
> It's currently designed to run from the c:\ folder
> look for this in the script:
> At %v_input% /interactive "c:\%0"
>
>
> @ECHO off
> SETLOCAL
> SET v_vbs=%temp%\~tmp.VBS
> SET v_cmd=%temp%\~tmp.cmd
> ECHO Set oFS=CreateObject("Scripting.FileSystemObject")>%v_vbs%
> ECHO tim=FormatDateTime(now+1/1440,vbShortTime)>>%v_vbs%
> ECHO oFS.CreateTextFile("%v_cmd%",2).Write "set v_input=">>%v_vbs%
> ECHO oFS.OpenTextFile("%v_cmd%",8).Write tim>>%v_vbs%
> cscript.exe //nologo %v_vbs%
> CALL %v_cmd%
> DEL %v_vbs%
> DEL %v_cmd%
> SET v_input
> ENDLOCAL & SET v_input=%v_input%
> :: place your actual commands here...
> At %v_input% /interactive "c:\%0"
>
> hth,
>
> D.
>
>
>
> smoochi3@gmail.com wrote:
>> You can always run the script when windows boots up and then have it
>> sleep for 5 minutes.
>>
>> Sean Grieco wrote:
>>
>>> Ok, so the "interactive" in AT worked nicely, however I do not see
>>> anywhere
>>> that I can have it run every 5 minutes, it is just based off daily....
>>>
>>> Can I run the AT command to run every 5 minutes or so?
>>>
>>>
>>>
>>> "Jason" <flajason@gmail.com> wrote in message
>>> news:1162927029.256174.279850@b28g2000cwb.googlegroups.com...
>>>
>>>> You pretty much solved it yourself based on your description of the
>>>> problem.
>>>> Unlike the RunAs command, when you run a scheduled task as another user
>>>> it does not run interactively. Any part of the task that requires user
>>>> input will not be displayed. I'd recommend removing any message boxes,
>>>> or recode it to use the Popup method instead, so you can at least set a
>>>> timeout on the response.
>>>>
>>>> - Jason
>>>> Sean Grieco wrote:
>>>>
>>>>> Hello,
>>>>>
>>>>> I have a script here that runs every 5 minutes in scheduled tasks.
>>>>> The
>>>>> script checks to see if the pc has a certain ip address and if it does
>>>>> it
>>>>> disables the dhcp client and displays a message. The problem is I
>>>>> have
>>>>> the
>>>>> task scheduled to run w/ the administrator's credentials. And unless
>>>>> the
>>>>> administrator is the one signed in to the pc, the dhcp client will
>>>>> disable
>>>>> but the message box does not display on the screen. It will give the
>>>>> message beep however. Then the task continually says "running"
>>>>> because
>>>>> it
>>>>> is waiting for the user to hit "ok", yet the user can not see the
>>>>> message
>>>>> box.
>>>>>
>>>>> What am i missing?
>>>>>
>>>>> Any help will be greatly appreciated.
>>>>>
>>
>>



Re: Script Not Totally Working in Scheduled Tasks by dNagel

dNagel
Wed Nov 08 14:34:45 CST 2006

See inline comments

D.

Sean Grieco wrote:
> D,
>
> That's a freakin' awesome script, it does the trick. However, I have a few
> quick questions.
>
> 1. Is there a way that the cmd box does not splash the time?
>
>
When you first execute the script call it like this
c:\sounds\new3.bat > nul

> 2. Can it be setup to delete all scheduled tasks first? Right now the way
> it is setup if you reboot it keeps the last task there, so when you log back
> in you have 2 tasks running, then the next time you have 3, etc.
>
to delete a scheduled task you call AT with the number of the task...
AT 13 /delete

to delete all tasks use
AT /delete

If you delete all tasks then you possibly break their scheduled virus
scans or whatever else they were using
the scheduler for outside of this task.
.
It would seem that in your login script that you should check to see if
you've already run this script.
One way would be to create a file in the script. This allows you to
check for a file to exist and decide
if you want to run the script or fall out.

:: Login Script usage example -- c:\sounds\new4.bat CHECKME > nul
::if we get a %1 (1st passed param == CHECKME)
:: then we know you want to see if we should run
:: this means if the key file exists then just
:: fall out and do nothing
@ECHO off
SET KeyFile=%temp%\Done.yet

if "%1"=="CHECKME" goto CHECKME
GOTO DOIT

:CHECKME
if exist %KeyFile% goto MESSAGE :: we know the intial execution is done.

:DOIT
echo.We Exist!>%KeyFile%
SETLOCAL
SET v_vbs=%temp%\~tmp.VBS
SET v_cmd=%temp%\~tmp.cmd
ECHO Set oFS=CreateObject("Scripting.FileSystemObject")>%v_vbs%
ECHO tim=FormatDateTime(now+1/(1440/10),vbShortTime)>>%v_vbs%
ECHO oFS.CreateTextFile("%v_cmd%",2).Write "set v_input=">>%v_vbs%
ECHO oFS.OpenTextFile("%v_cmd%",8).Write tim>>%v_vbs%
cscript.exe //nologo %v_vbs%
CALL %v_cmd%
DEL %v_vbs%
DEL %v_cmd%
SET v_input
ENDLOCAL & SET v_input=%v_input%

ECHO RUN THE REAL CODE
At %v_input% /interactive "%0" > nul

:MESSAGE
::already initialized the loop code so just fall out
> 3. Can these tasks be hidden when created? That way the user does not see
> and cannot delete it....
>
http://groups.google.com/group/microsoft.public.windowsxp.general/browse_thread/thread/564ff2bbac76c6cb/8c2d590818e6a2c2?lnk=st&q=hide+scheduled+tasks+from+the+user&rnum=1&hl=en#8c2d590818e6a2c2

> Thanks again, great script!
>
Thanks,

D.

Re: Script Not Totally Working in Scheduled Tasks by Sean

Sean
Wed Nov 08 14:49:55 CST 2006

D,

Thanks for the quick response, I guess I should have been more specific.
The >nul does not display the time, however, I don't want any black cmd box
opening. Is there a way to run that hidden?

Thanks, Sean

"dNagel" <NOTGrandNagel@NotMail.com> wrote in message
news:OECa7V3AHHA.204@TK2MSFTNGP04.phx.gbl...
> See inline comments
>
> D.
>
> Sean Grieco wrote:
>> D,
>>
>> That's a freakin' awesome script, it does the trick. However, I have a
>> few quick questions.
>>
>> 1. Is there a way that the cmd box does not splash the time?
>>
>>
> When you first execute the script call it like this
> c:\sounds\new3.bat > nul
>
>> 2. Can it be setup to delete all scheduled tasks first? Right now the
>> way it is setup if you reboot it keeps the last task there, so when you
>> log back in you have 2 tasks running, then the next time you have 3, etc.
>>
> to delete a scheduled task you call AT with the number of the task...
> AT 13 /delete
>
> to delete all tasks use
> AT /delete
>
> If you delete all tasks then you possibly break their scheduled virus
> scans or whatever else they were using
> the scheduler for outside of this task.
> .
> It would seem that in your login script that you should check to see if
> you've already run this script.
> One way would be to create a file in the script. This allows you to check
> for a file to exist and decide
> if you want to run the script or fall out.
>
> :: Login Script usage example -- c:\sounds\new4.bat CHECKME > nul
> ::if we get a %1 (1st passed param == CHECKME)
> :: then we know you want to see if we should run
> :: this means if the key file exists then just
> :: fall out and do nothing
> @ECHO off
> SET KeyFile=%temp%\Done.yet
>
> if "%1"=="CHECKME" goto CHECKME
> GOTO DOIT
>
> :CHECKME
> if exist %KeyFile% goto MESSAGE :: we know the intial execution is done.
>
> :DOIT
> echo.We Exist!>%KeyFile%
> SETLOCAL
> SET v_vbs=%temp%\~tmp.VBS
> SET v_cmd=%temp%\~tmp.cmd
> ECHO Set oFS=CreateObject("Scripting.FileSystemObject")>%v_vbs%
> ECHO tim=FormatDateTime(now+1/(1440/10),vbShortTime)>>%v_vbs%
> ECHO oFS.CreateTextFile("%v_cmd%",2).Write "set v_input=">>%v_vbs%
> ECHO oFS.OpenTextFile("%v_cmd%",8).Write tim>>%v_vbs%
> cscript.exe //nologo %v_vbs%
> CALL %v_cmd%
> DEL %v_vbs%
> DEL %v_cmd%
> SET v_input
> ENDLOCAL & SET v_input=%v_input%
>
> ECHO RUN THE REAL CODE
> At %v_input% /interactive "%0" > nul
>
> :MESSAGE
> ::already initialized the loop code so just fall out
>> 3. Can these tasks be hidden when created? That way the user does not
>> see and cannot delete it....
>>
> http://groups.google.com/group/microsoft.public.windowsxp.general/browse_thread/thread/564ff2bbac76c6cb/8c2d590818e6a2c2?lnk=st&q=hide+scheduled+tasks+from+the+user&rnum=1&hl=en#8c2d590818e6a2c2
>
>> Thanks again, great script!
>>
> Thanks,
>
> D.



Re: Script Not Totally Working in Scheduled Tasks by dNagel

dNagel
Wed Nov 08 15:59:39 CST 2006

>D,
>
>Thanks for the quick response, I guess I should have been more specific.
>The >nul does not display the time, however, I don't want any black cmd box
>opening. Is there a way to run that hidden?
>
>Thanks, Sean




ok, now we have three files....

To use this place all three files in the same location.
Call login.vbs in your login script instead of the .bat

make sure you delete this temp file before retrying this procedure...
( or when you have to re-create the task using login.vbs )
del %temp%\Done.yet

Send your cashier check to : (just kidding)

D.

login.vbs
----------------------------------------------------------------------
Const Hide = 0: Dim VBS, ACT, path
Function GetPath()
path = WScript.ScriptFullName
GetPath = Left(path, InstrRev(path, "\"))
End Function
Set Act = CreateObject("Wscript.Shell")
VBS = trim(GetPath) & "\new4.bat """ & trim(GetPath) & "\"" CHECKME"
Act.Run(VBS),Hide,True

normal.vbs
------------------------------------------------------------------------
Const Hide = 0: Dim VBS, ACT, path
Function GetPath()
path = WScript.ScriptFullName
GetPath = Left(path, InstrRev(path, "\"))
End Function
Set Act = CreateObject("Wscript.Shell")
VBS = trim(GetPath) & "\new4.bat """ & trim(GetPath) & "\"""
Act.Run(VBS),Hide,True

new4.bat
---------------------------------------------------------------------
:: Login Script usage example -- c:\sounds\new4.bat CHECKME > nul
::if we get a %1 (1st passed param == CHECKME)
:: then we know you want to see if we should run
:: this means if the key file exists then just
:: fall out and do nothing
@ECHO off
SET KeyFile=%temp%\Done.yet

if "%2"=="CHECKME" goto CHECKME
GOTO DOIT

:CHECKME
if exist %KeyFile% goto MESSAGE :: we know the intial execution is done.

:DOIT
echo.We Exist!>%KeyFile%
SETLOCAL
SET v_vbs=%temp%\~tmp.VBS
SET v_cmd=%temp%\~tmp.cmd
ECHO Set oFS=CreateObject("Scripting.FileSystemObject")>%v_vbs%
ECHO tim=FormatDateTime(now+1/(1440/1),vbShortTime)>>%v_vbs%
ECHO oFS.CreateTextFile("%v_cmd%",2).Write "set v_input=">>%v_vbs%
ECHO oFS.OpenTextFile("%v_cmd%",8).Write tim>>%v_vbs%
cscript.exe //nologo %v_vbs%
CALL %v_cmd%
DEL %v_vbs%
DEL %v_cmd%
SET v_input
ENDLOCAL & SET v_input=%v_input%

ECHO RUN THE REAL CODE
At %v_input% /interactive "%1normal.vbs" > nul

:MESSAGE
::already initialized the loop code so just fall out


Re: Script Not Totally Working in Scheduled Tasks by dNagel

dNagel
Wed Nov 08 16:04:25 CST 2006

this line

path = WScript.ScriptFullName GetPath = Left(path, InstrRev(path, "\"))

should have been split into two

path = WScript.ScriptFullName
GetPath = Left(path, InstrRev(path, "\"))

D.

dNagel wrote:
>> D,
>>
>> Thanks for the quick response, I guess I should have been more
>> specific. The >nul does not display the time, however, I don't want
>> any black cmd box opening. Is there a way to run that hidden?
>>
>> Thanks, Sean
>
>
>
>
> ok, now we have three files....
>
> To use this place all three files in the same location.
> Call login.vbs in your login script instead of the .bat
>
> make sure you delete this temp file before retrying this procedure...
> ( or when you have to re-create the task using login.vbs ) del
> %temp%\Done.yet
>
> Send your cashier check to : (just kidding)
>
> D.
>
> login.vbs
> ----------------------------------------------------------------------
> Const Hide = 0: Dim VBS, ACT, path
> Function GetPath()
> path = WScript.ScriptFullName GetPath = Left(path, InstrRev(path, "\"))
> End Function
> Set Act = CreateObject("Wscript.Shell")
> VBS = trim(GetPath) & "\new4.bat """ & trim(GetPath) & "\"" CHECKME"
> Act.Run(VBS),Hide,True
>
> normal.vbs
> ------------------------------------------------------------------------
> Const Hide = 0: Dim VBS, ACT, path
> Function GetPath()
> path = WScript.ScriptFullName
> GetPath = Left(path, InstrRev(path, "\"))
> End Function
> Set Act = CreateObject("Wscript.Shell")
> VBS = trim(GetPath) & "\new4.bat """ & trim(GetPath) & "\"""
> Act.Run(VBS),Hide,True
>
> new4.bat
> ---------------------------------------------------------------------
> :: Login Script usage example -- c:\sounds\new4.bat CHECKME > nul
> ::if we get a %1 (1st passed param == CHECKME)
> :: then we know you want to see if we should run
> :: this means if the key file exists then just
> :: fall out and do nothing
> @ECHO off
> SET KeyFile=%temp%\Done.yet
>
> if "%2"=="CHECKME" goto CHECKME
> GOTO DOIT
>
> :CHECKME
> if exist %KeyFile% goto MESSAGE :: we know the intial execution is done.
>
> :DOIT
> echo.We Exist!>%KeyFile%
> SETLOCAL
> SET v_vbs=%temp%\~tmp.VBS
> SET v_cmd=%temp%\~tmp.cmd
> ECHO Set oFS=CreateObject("Scripting.FileSystemObject")>%v_vbs%
> ECHO tim=FormatDateTime(now+1/(1440/1),vbShortTime)>>%v_vbs%
> ECHO oFS.CreateTextFile("%v_cmd%",2).Write "set v_input=">>%v_vbs%
> ECHO oFS.OpenTextFile("%v_cmd%",8).Write tim>>%v_vbs%
> cscript.exe //nologo %v_vbs%
> CALL %v_cmd%
> DEL %v_vbs%
> DEL %v_cmd%
> SET v_input
> ENDLOCAL & SET v_input=%v_input%
>
> ECHO RUN THE REAL CODE
> At %v_input% /interactive "%1normal.vbs" > nul
>
> :MESSAGE
> ::already initialized the loop code so just fall out
>

Re: Script Not Totally Working in Scheduled Tasks by Sean

Sean
Thu Nov 09 07:43:59 CST 2006

that did the trick D. Thanks a lot, you helped me out a lot.



"dNagel" <NOTGrandNagel@NotMail.com> wrote in message
news:OCKgBI4AHHA.996@TK2MSFTNGP02.phx.gbl...
> this line
>
> path = WScript.ScriptFullName GetPath = Left(path, InstrRev(path, "\"))
>
> should have been split into two
>
> path = WScript.ScriptFullName
> GetPath = Left(path, InstrRev(path, "\"))
>
> D.
>
> dNagel wrote:
>>> D,
>>>
>>> Thanks for the quick response, I guess I should have been more specific.
>>> The >nul does not display the time, however, I don't want any black cmd
>>> box opening. Is there a way to run that hidden?
>>>
>>> Thanks, Sean
>>
>>
>>
>>
>> ok, now we have three files....
>>
>> To use this place all three files in the same location.
>> Call login.vbs in your login script instead of the .bat
>>
>> make sure you delete this temp file before retrying this procedure...
>> ( or when you have to re-create the task using login.vbs ) del
>> %temp%\Done.yet
>>
>> Send your cashier check to : (just kidding)
>>
>> D.
>>
>> login.vbs
>> ----------------------------------------------------------------------
>> Const Hide = 0: Dim VBS, ACT, path
>> Function GetPath()
>> path = WScript.ScriptFullName GetPath = Left(path, InstrRev(path, "\"))
>> End Function
>> Set Act = CreateObject("Wscript.Shell")
>> VBS = trim(GetPath) & "\new4.bat """ & trim(GetPath) & "\"" CHECKME"
>> Act.Run(VBS),Hide,True
>>
>> normal.vbs
>> ------------------------------------------------------------------------
>> Const Hide = 0: Dim VBS, ACT, path
>> Function GetPath()
>> path = WScript.ScriptFullName
>> GetPath = Left(path, InstrRev(path, "\"))
>> End Function
>> Set Act = CreateObject("Wscript.Shell")
>> VBS = trim(GetPath) & "\new4.bat """ & trim(GetPath) & "\"""
>> Act.Run(VBS),Hide,True
>>
>> new4.bat
>> ---------------------------------------------------------------------
>> :: Login Script usage example -- c:\sounds\new4.bat CHECKME > nul
>> ::if we get a %1 (1st passed param == CHECKME)
>> :: then we know you want to see if we should run
>> :: this means if the key file exists then just
>> :: fall out and do nothing
>> @ECHO off
>> SET KeyFile=%temp%\Done.yet
>>
>> if "%2"=="CHECKME" goto CHECKME
>> GOTO DOIT
>>
>> :CHECKME
>> if exist %KeyFile% goto MESSAGE :: we know the intial execution is done.
>>
>> :DOIT
>> echo.We Exist!>%KeyFile%
>> SETLOCAL
>> SET v_vbs=%temp%\~tmp.VBS
>> SET v_cmd=%temp%\~tmp.cmd
>> ECHO Set oFS=CreateObject("Scripting.FileSystemObject")>%v_vbs%
>> ECHO tim=FormatDateTime(now+1/(1440/1),vbShortTime)>>%v_vbs%
>> ECHO oFS.CreateTextFile("%v_cmd%",2).Write "set v_input=">>%v_vbs%
>> ECHO oFS.OpenTextFile("%v_cmd%",8).Write tim>>%v_vbs%
>> cscript.exe //nologo %v_vbs%
>> CALL %v_cmd%
>> DEL %v_vbs%
>> DEL %v_cmd%
>> SET v_input
>> ENDLOCAL & SET v_input=%v_input%
>>
>> ECHO RUN THE REAL CODE
>> At %v_input% /interactive "%1normal.vbs" > nul
>>
>> :MESSAGE
>> ::already initialized the loop code so just fall out
>>