Task run as different user windows xp

I have a bunch of files (programs) in c:\windows\tasks that when setting up a new system based on the type of machine (manager or training) I have to change the run as to administrator or manager depending on the file. Is there a way to simplify this process using maybe a macro? There are around 30 files that permissions have to be changed.  So when setting up machines this can be time consuming.  Thanks for the help.  Steps would be great.
TechyTAsked:
Who is Participating?
 
X-treemCommented:
check http://technet.microsoft.com/en-us/library/bb490996.aspx
eg:
schtasks /create /tn ""My App"" /tr c:\apps\myapp.exe /sc weekly /d ""MON WED FRI"" /m MAY,JUN /st 06:00:00

also another method:
http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/Server/2003_Server/Q_26877191.html
0
 
Rich RumbleSecurity SamuraiCommented:
I wrote a "drag and drop" runas script, requires you to store the password in plain-text, but if your only using it temporarily this would cut down on on typing the passwords. Just drag the program to the vbs file and drop: http://xinn.org/RunasVBS.html
-rich
0
 
X-treemCommented:
you can use a script to set up the tasks automatically using eg the schtasks command
http://technet.microsoft.com/en-us/library/cc738335%28v=ws.10%29.aspx

create 2 batch files, one for admin and one for manager and launch depending on the requirement

delete the batch file after having executed it on the pc as it contains plain text passwords
0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

 
TechyTAuthor Commented:
trying to change run as to managerHere is what i'm really trying to do...
I have these job files shown below.
Some run as administor and some need to run as manager.
I'm wanting to do this with a bat file or something so i don't have to open each and everyone one to change..

 Volume in drive C has no label.
 Volume Serial Number is B0E2-034D

 Directory of C:\WINDOWS\Tasks

09/19/2012  04:53 PM               188 Aud.job
09/19/2012  04:42 PM               282 FTPSRV.job
09/20/2012  11:30 AM               258 washFiles.job
09/19/2012  06:00 PM               190 bkup.job
09/19/2012  04:43 PM               254 CleanUp1.job
09/20/2012  12:00 PM             1,707 directorylist.txt
09/20/2012  10:00 AM               294 DTTW_Transfer.job
09/19/2012  04:44 PM               290 ERPTickImprt.job
09/19/2012  04:45 PM               232 FPRXport.job
09/19/2012  08:00 PM               308 FromTruckWash.job
09/19/2012  04:45 PM               282 LoadTasks.job
09/19/2012  04:46 PM               294 PLDownloadToHO.job
09/20/2012  07:45 AM               326 PLUpload.job
09/19/2012  04:46 PM               244 PollingAgent.job
09/20/2012  12:30 AM               244 ProcessIRsTW.job
09/20/2012  05:15 AM               256 ResetWeek.job
09/20/2012  12:25 AM               244 SBHActualExtract.job
09/19/2012  04:47 PM               240 SBHMghrsExt.job
09/20/2012  02:00 AM               276 ScheduledBioExtract.job
09/19/2012  04:47 PM               238 TmpMgmtExport.job
09/19/2012  04:48 PM               230 TrainWarn.job
09/20/2012  11:45 AM               246 TWEMAExport.job
09/20/2012  07:47 AM               270 TWOSELoad.job
09/19/2012  04:51 PM               286 updateini.job
09/20/2012  12:00 PM               316 UploadToTruckWash.job
09/20/2012  10:00 AM               286 VRTW.job
10/05/2009  10:40 AM               258 wintounix.job
              27 File(s)          8,539 bytes
               0 Dir(s)  73,741,611,008 bytes free

Open in new window

See where it says Run as:
I want to change it ..\Manager or whatever user I prefer.
0
 
X-treemCommented:
start>run>cmd and type: schtasks /create /? to verify the syntax.

create 2 (or more) batch files and fill them with the commands to create the tasks,
eg:
REM first task from screen shot, runas admin, schedule: daily at 13hrs
SCHTASKS /Create /RU BRITWASH\Administrator /RP adminpassword /SC DAILY /TN aud /TR c:\audit.bat /ST 13:00:00
etc....

once the files are ready, you only need to double click to launch and all the jobs are created
0
 
Rich RumbleSecurity SamuraiCommented:
You can use the Vbscripts I linked to, call the batch files directly...
Option explicit
Dim oShell
set oShell= Wscript.CreateObject("WScript.Shell")
oShell.Run "RunAs /noprofile /user:administrator ""C:\Audit.bat"""
WScript.Sleep 100
oShell.Sendkeys "yourpassword~"
WScript.Sleep 100
oShell.Run "RunAs /noprofile /user:administrator ""C:\FTPSRV.bat"""
WScript.Sleep 100
oShell.Sendkeys "yourpassword~"
WScript.Sleep 100
oShell.Run "RunAs /noprofile /user:administrator ""C:\washFiles.bat"""
WScript.Sleep 100
oShell.Sendkeys "yourpassword~"
WScript.Sleep 100
oShell.Run "RunAs /noprofile /user:administrator ""C:\bkup.bat"""
WScript.Sleep 100
oShell.Sendkeys "yourpassword~"
WScript.Sleep 100

Wscript.Quit

Open in new window

and so on... You can even specify the manager username and cred's in the same VBS Again replace "yourpassword" with the proper one, and leave the tilde in the quotes (this means "enter"). The batch files will run as the user in the script.Run the vbscript from a cmd prompt "cscript /nologo admin_tasks.vbs"
-rich
0
 
Rich RumbleSecurity SamuraiCommented:
Remember the passwords are not secure this way, but allow you to run the batch files all in one swoop. VBE encoding isn't the best protection, don't leave the VBS file lying around!
-rich
0
 
TechyTAuthor Commented:
Running this script though will it take an keep the job preferences? For instance Weekly 10am mon-friday  duraton 1 hour?
Cause i need all that stuff in the .job file to stay the same just change how it runs.
Thanks
0
 
X-treemCommented:
nope, it runs the jobs one by one with an interval of 0.1 seconds

in order to schedule them you'll need to follow my solution ....
0
 
Rich RumbleSecurity SamuraiCommented:
I agree, using SCHTASKS is the most SECURE way of running these Jobs. I thought they were temporary or one time scripts. http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/schtasks.mspx?mfr=true
Recreating using a batch file, is best. Also remember that when the jobs are stored, if the password is reset (if using domain users) then the jobs will fail after the password is reset/changed.
-rich
0
 
TechyTAuthor Commented:
I thank you guys for the help, wish i could award points to x-treem for this since his solution is more of what i need.
I have a question though. I was making the bat file on windows 7 and didn't occur to me that it was an xp machine that i would be setting up. in any case i do not see the options to setup the duration in schtasks and also how do you multiple dates? Here is some code if you will that i put in the batch file
REM some file
SCHTASKS /Create /RU BRITWASH\Manager /RP passwordhere /SC WEEKLY /D MON TUES WEDS THU FRI /TN somefile /TR "c:\Program Files\somefile.exe" /ST 10:30 /DU 01:00

Open in new window


i'm not sure how to make the duration 1 hour and the run to be mon-fri
thanks.
0
 
Rich RumbleSecurity SamuraiCommented:
I've requested the attention of the moderators to switch the points.
-rich
0
 
TechyTAuthor Commented:
think i see the problem
0
 
TechyTAuthor Commented:
Thanks got it working.. Went an applied some if statements and Set statements to get what type user it is.  thanks again!!!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.