1
votes

I'm having a problem with scheduling a task in Windows 7 I m creating a task which is mapped to a bat file to execute, here is my .bat file :

cd "C:\soft\" 
Start excel "" "AD Auto Run.xlsm"

its working automaticaly and manually when the option (radio button) "Run only when the user is logged on" is selected.

but the automatic/manual RUN is not working when the option (radio button) "Run whether user logged on or not" is selected.

3
Can you define 'working'. What is supposed to happen? What does your Excel file do? Can you include the code from it?Dave Sexton
the excel file generate reportsuser1863359
Does it store the reports on a mapped drive?Dave Sexton
look, here is a description of what I make : I created a .bat file that launch a .xlsm (1) file, in this file I call another .xlsm (2) file that generate me the reports , I proceeded in this manner because otherwise the 2nd file will be opened in a already opened instance of excel which can cause problem if I have excel file already open. that's why I proceeded in this way. (.bat-->(1).xlsm-->(2).xlsm so the seconde xlsm will be opened in the fisrt one)user1863359
But are you using a mapped drive? Mapped drives will only be available once a user has logged in.Dave Sexton

3 Answers

1
votes

I resolved the issue by performing these steps:

Create the empty Desktop folders at the below path:

C:\Windows\System32\config\systemprofile\Desktop C:\Windows\SysWOW64\config\systemprofile\Desktop

Make sure user has “log on as batch job” permission.

To enable this please follow below steps:

a) Go to the Start menu.

b) Type secpol.msc. and press Enter.

c) The Local Security Policy manager opens.

d) Go to Security Settings - Local Policies - User Rights Assignment node.

e) Double click Log on as a batch job on the right side.

f) Click Add User or Group.

g) Select the user.

h) Click OK.

Create a file and save it with .cmd extension. The .cmd file should contain below cmd:

cscript.exe “<path to .vbs file>”

In the scheduler, give the path as follows:

• Program/script: filename (.cmd filename)

• Start in(optional): file path (path to .cmd file)

0
votes

Check the mapped drive in your batch file, by adding a diagnostic command after you map the drive.

Assuming M: is the mapped drive:

if exist "M:\soft\AD Auto Run.xlsm" (
   >>"c:\folder with write permissions\file.log" echo map ok
   ) else (
   >>"c:\folder with write permissions\file.log" echo map FAILED
 )
0
votes

I made some changes and it appears to work like a charm. The issue like I previously stated that the excel is creating some issue. I found that the excel file was not able to save the record set output when the user account is logged off. So You have to create a folder (or two on a 64bit-windows):

(32Bit, always) C:\Windows\System32\config\systemprofile\Desktop (64Bit) C:\Windows\SysWOW64\config\systemprofile\Desktop After creation of the folder, my program is working fine.