.vbs script not running under task scheduler windows server 2012

Hi,

I am trying to run a .vbs script using task scheduler under windows server 2012 but it will not run unless I use the local administrator username and check the option " run only when user is logged on".

if I run the .vbs script manually it works fine.   I have also try creating a .bat file that will run the .vbs script and it works fine if run manually.  If I schedule the .bat file to run in windows server 2012 it will not run.  Task schedule don't show any error messages.



Any help is appreciated.

thanks,
tech-gineerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

NVITEnd-user supportCommented:
> Task schedule don't show any error messages
What does the Last Run Result column show?

Also, what are your Actions, Settings
Program / script
Add arguments
Qlemo"Batchelor", Developer and EE Topic AdvisorCommented:
Does the VBS use any GUI components? Can you tell us what it is doing exactly?
tech-gineerAuthor Commented:
Hi to all,

What I am trying to accomplish is running a .vbs script that will open the excel file and make some changes, and then it save the excell file as .cnm    The file runs fine when I double click on it, but when I schedule it nothing happens.  There is no GUI as everything runs in the background.



The las run result says " the operation completed susccesfully. (0x0)

I also receive this message under History  --   "Task Scheduler successfully finished "{b1f3fa4c-d848-48f9-a007-07e38bd33f5c}" instance of the "\Script test run" task for user "server1\Administrator"."  but nothing really happens.

My action settings are as follow:

Action: start a program

Program/script:
c:\scripts\testscript.bat

Start in (optional)
c:\scripts


I did a couple of testing and notices when I pick the "ADMINISTRATORS GROUP"  as the following user account It works ONLY if I log in or if I lock the server.  When I reboot the server nothing happens.
Active Protection takes the fight to cryptojacking

While there were several headline-grabbing ransomware attacks during in 2017, another big threat started appearing at the same time that didn’t get the same coverage – illicit cryptomining.

NVITEnd-user supportCommented:
Try...

Program / script: cmd.exe
Add arguments: /c c:\scripts\testscript.bat
Qlemo"Batchelor", Developer and EE Topic AdvisorCommented:
And .cnm means ... ?
AFAIK you need a logged in session to use Excel, even if you do not see any window.
Best to search for another way to get your file converted.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
tech-gineerAuthor Commented:
Hi,

NVIT -  I did the changes you recommended and still no good.  The strange thing is that it only works when I choose the script to run under the "administrators group" and "run only when user is logged on".  Eventually I have to login to the server and it will work even if the server is locked, but it will not work with any other account.  Do you know why it only works with administrators group and not other accoutns?

Qmelo - you might be right, I probably need a session to run the script which uses excel to change the file extension, but if this is true then you are saying that a locked computer can have an excell session on the background?

Thanks,
Qlemo"Batchelor", Developer and EE Topic AdvisorCommented:
Yes, a locked session suffices for Excel. I'm not clear about the admin group requirement, that should not be the case.
NVITEnd-user supportCommented:
> ...I have to login to the server and it will work even if the server is locked, but it will not work with any other account
Has the user you are trying to run task as ever logged on that server? If not, maybe because that local user profile doesn't exist.

Regardless of the user, as Qlemo said and you've confirmed, you'd still need a running user session.
tech-gineerAuthor Commented:
Hi Experts,

Qlemo was right it will never work because a session is needed to run excel.  We are looking for another way to run the script without the excel program.  Any suggestions?

Thanks,
Bill PrewIT / Software Engineering ConsultantCommented:
What is a CNM file, I'm not aware of that being an Excel format.

Also, is the data you planned to get from the Excel file in an *.XLS* file, or is it actually a CSV that you are opening in Excel.

If it isn't a CSV today, could you perhaps get a CSV version of the data rather than an XLS* format?

If the data is indeed in an excel format file (*.XLS*) then there is no other easy way to access that data without having Excel installed, and then starting an Excel session to load and act on the file.

~bp
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Server 2012

From novice to tech pro — start learning today.