Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Need help with a Scheduled Task problem. Change PC name it runs under

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,54308
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Need help with a Scheduled Task problem. Change PC name it runs under
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Need help with a Scheduled Task problem. Change PC name... - 12/13/2007 9:22:48 PM   
  midi25

 

Posts: 2
Score: 0
Joined: 12/13/2007
Status: offline
Hi is there a way how I can change the pc name that a Scheduled task runs under?

eg. I have imaged 20 pcs at work and the scheduled task on every cloned PC is using the computer account name of the master pc. So it never runs on the other machines.  

I need a script that will read the pc name on every machines and change the pcnanme/account that the Scheduled Task runs under.

Or I need a script that will read the pc name and create a Scheduled Task that runs under a specified local user account.
I found something on MS Tech Net, but I dont fully understand how it works.

eg:

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
   & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set objNewJob = objWMIService.Get("Win32_ScheduledJob")

errJobCreated = objNewJob.Create _
   ("Notepad.exe", "********123000.000000-420", _
       True , 1 OR 4 OR 16, , , JobID)
Wscript.Echo errJobCreated

Can someone please help.

Thanks
 
 
Post #: 1
 
 RE: Need help with a Scheduled Task problem. Change PC ... - 12/13/2007 11:35:51 PM   
  Meg


Posts: 126
Score: 2
Joined: 7/13/2006
From: Australia
Status: offline
Do you use sysprep on the images first? if not that may help.

Your script will set a scheduled task on the computer it is run on, change the line strComputer = "." to strComputer = "pc002" to set the scheduled task on pc002.
According to microsoft, if you set a task this way you can not edit it later with the GUI.

You can also run c:\windows\system32\Schtasks.exe with the necessessary switches to set a scheduled task.
Example in my last script - task monitor

strCSV = "outputfile.csv"
strCMD="cmd /c c:\windows\system32\Schtasks.exe /S " & strComputer & " /query /fo csv /NH /v > " & strCSV
objShell.Run strCmd,0,True


This snipit will Query computer for scheduled task information, change the switches to actually set a task

Good luck.

(in reply to midi25)
 
 
Post #: 2
 
 RE: Need help with a Scheduled Task problem. Change PC ... - 12/14/2007 12:26:05 AM   
  midi25

 

Posts: 2
Score: 0
Joined: 12/13/2007
Status: offline
Thanks

But I have over 20 machines that all need changing.

I just need a script that creates a task and runs under the local admin account.

eg:

Create scheduled task that runs every 30mins and runs under the local admin account.

Thanks  

(in reply to Meg)
 
 
Post #: 3
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Need help with a Scheduled Task problem. Change PC name it runs under Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts