Question

I have a .vbs file called test.vbs. And this is running test.bat file silently.

In test.bat file,

CD.>"C:\folder\empty.srt"
dir /b /s "C:\folder" | findstr /m /i "\.srt$" > C:\old.txt
CD.>C:\new.txt
.
.
echo for /f "delims=" %%a in ('findstr /G:%new% /I /L /B /V %old%') do (@echo %%~nxa >> C:\added.txt)
.
.
CD.>C:\added.txt
del "C:\folder\empty.srt"

When I run test.vbs manually .bat file works fine. But when I run test.vbs from Windows' Scheduled Tasks (command is: C:\test.vbs (tried wscript test.vbs) )

Only creates empty.srt and removes empty.srt. The other commands are not working. I don't understand why (maybe administrator priviliges (Account is administrator too).

I thought running as administrator would solve the problem. Or is there another way to do this? How can I do that?

edit: Also working when I run this command from CMD --> wscript C:\test.vbs

Also its working fine on Windows 8

Was it helpful?

Solution

I also ran into this issue a while back, as well as have answered a variation of this issue before.

If it's a 64 bit operating system, then you need to open the script via "C:\windows\syswow64\cscript.exe your_vbs_code.vbs" if not, just use "C:\windows\system32\cscript.exe".

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top