Jump to content


This is a ready-only archive of the InstallSite Forum. You cannot post any new content here. / Dies ist ein Archiv des InstallSite Forums. Hier können keine neuen Beiträge veröffentlicht werden.
Photo

How to change a scheduled task's account to 'Syste


5 replies to this topic

peterbi

peterbi
  • Full Members
  • 19 posts

Posted 12 October 2006 - 21:46

Hi,

Pasted following is a post I wrote to installshield groups. I am trying my luck here :-)


I used _LaunchAppEx() to execute a commandline to change a scheduled task as following (to change 'MyTask' to under 'System' account):

_LaunchAppEx("schtasks", "/change /tn \"MyTask\" /ru \"System\"", WAIT, SW_HIDE, -1, nvExitCode);

but the nvExitCode always returns 1, instead of 0.

The result is that the task I want to change is not changed at all, using the same commandline manually (schtask /change /tn "MyTask" /ru "System") changed the task.

I don't know how to look into further on why nvExitCode returns 1 but not 0? Anybody can give a hint?

Or is there a better way I should use to do the work (manual way is not considered)? I have successfully executed all commands needed with _LaunchAppEx() in my IS Script functions so far, what special points for this 'schtasks'? I remembered in one thread saying that VBS should be used, but can't remember the reasons.

Even if this (_LaunchAppEx()) way doesn't work, I would like to know why :-)


Thanks,
Peter


I also tried HideAppAndWait() to wrap the command, the function returned 0, but the task account was not changed.


Stefan Krueger

Stefan Krueger

    InstallSite.org

  • Administrators
  • 13,269 posts

Posted 13 October 2006 - 15:37

Is there a documentation about the exit codes of schtasks? And did you check the result code of _LaunchAppEx?

Did you try with schtasks.exe (I believe you must include the extension)? Maybe also try with the full path to schtasks.exe.

peterbi

peterbi
  • Full Members
  • 19 posts

Posted 13 October 2006 - 19:21

Stefan,

Thanks so much for your reply and suggestions.

I tried items you mentioned, both methods (LaunchAppEx and LaunchAppAndWait) returned good results (0).

Once I added the .exe to schtasks, the nvExitCode in LaunchAppEx() became 0 now, but unfortunately the account still remained unchanged. I also tried full path, it's the same (nvExitcode=0, but account not changed).

I think it could be related to the limitation of right of Windows Installer (or InstallShield?), but not sure what that is. BTW I am using Basic project.

If you want to try it by yourself, there is an easy way (in Win2003): Start->Settings->Control panel->Scheduled Tasks, then add a task (I selected CALCULATOR), but don't enter password for the default 'administrator' account, click 'ok' to complete (it will warn you that the task may not be able to run without inputing password, just click 'ok'). Now if you execute [schtasks /change /tn "CALCULATOR" (or whatevername you use) /ru "System"], you will see the task 'run as' is changed to 'NT AUTHORITY/SYSTEM', and you can 'run' it.

You can delete the task and recreate it, then try with a package simply with the command wrapped as a custom action, and see if you can get more clue what's going one behind it. It would be great if you can post your comments on the reason (something I did wrong, or why IS script can't have it done).


Thanks again,
Peter



peterbi

peterbi
  • Full Members
  • 19 posts

Posted 18 October 2006 - 18:02

Since InstallShield can't make "schtasks /change" work (at least for me now), is there a way that setup.exe can trigger execution of a .vbs/.cmd/.bat file?


Thanks,
Peter

halciber

halciber
  • Full Members
  • 25 posts

Posted 01 November 2006 - 14:35

Hi Peterbi,

As luck has it, I needed to get my install to set up a program to launch automatically at log in time. I came up with this:

Get your install to set the registry with the following:

Key: HKLM\Software\MicrosoftWindows\CurrentVersion\Run

Name: YourAppsName
Type: REG_SZ
Data: Path to your app+ app name, for example:

c:\Program Files\YourAppsName\YourAppsName.exe

I tested this manually (ie typing it into the registry) as well as getting the install to run this, and both worked properly.

I hope this helps.

Sincerely,
Mike Goldweber



hmoeckel

hmoeckel
  • Full Members
  • 97 posts

Posted 30 November 2007 - 11:57

Hi

I found this link about creating scheduled tasks in both Windows 2000 and Windows 2003
http://community.mac...ad.php?t=154655

maybe it helps

hans