Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Running vbscript using schedule task

Status
Not open for further replies.

ajtsystems

IS-IT--Management
Jan 15, 2009
80
GB
Hi,

I am having problems running a Vbscript using server 2008 R2. When I run the script manually a file is created with a few lines of text, it is fine and works. When it runs under a scheduled task the file is created but never filled and the taks never stops.

Looking into it its permissions related.

Does anyone have any more information.

I have managed to capture the error using this batch file

@echo off
echo %date% %time% %username% >> c:\test.txt
cscript //nologo c:\1.vbs 1>>c:\test.txt 2>>&1
echo %date% %time% >> c:\test.txt

The error is permission denied but I am running under an admin account...

Any help would be good
 
This I believe you will find is caused by the security enhancements of server 2008. Something that drives me crazy!

Try using the wrapper around your code. It will launch the script as elevated user.

Code:
If WScript.Arguments.length =0 Then
  Set objShell = CreateObject("Shell.Application")
  'Pass a bogus argument with leading blank space, say [ uac]
  objShell.ShellExecute "wscript.exe", Chr(34) & _
  WScript.ScriptFullName & Chr(34) & " uac", "", "runas", 1
Else
  'Add your code here
End If

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top