Windows Share Path

Vino vino.bheeman at hotmail.com
Sat Dec 2 07:48:14 UTC 2017


On Saturday, 2 December 2017 at 05:08:27 UTC, Vino wrote:
> Hi All,
>
>   Request your help, I have samll program which validates the 
> file path, the script run perfectly when i run it manually, but 
> if i run it via windows task scheduler i am getting "Invalid 
> File Path <Path> or Path do not Exist", The path is a windows 
> share, Even tried to add the net path as 
> "\\\\server\\share$\\BACKUP" for the parameter "p" in the below 
> code but no luck, the same error.
>
> Even tried to call this program via .bat script not luck same 
> error
>
> Windows .BAT program
> @echo off
> cd D:\DScript
> start /D D:\DScript /B /WAIT D:\DScript\TestDir.exe
> exit
>
> Program
> import std.stdio;
> import std.file;
> import std.path;
> import std.system;
>
> void main()
> {
>  version (Windows) {
>  auto p = "N:\\\BACKUP";
>   if (!p.isValidPath && !p.strip.isValidFilename || !p.exists ) 
> { writeln("Invalid File Path (", p, ") or Path do not Exist"); }
>   else { writeln("File Exist":, p); }
> }
>   }
>
> From,
> Vino.B

Even tried with the below code, it works manually but not via 
Windows scheduler with option "Run whether user is logged on or 
not"

Program:
import std.stdio;
import std.file;
import std.path;
import std.string;
import std.process;

void main()
{
auto result = 
execute(["C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe", "-command", "New-PSDrive -Name", "R", "-PSProvider FileSystem -Root", "\\\\bp1xeuss005-f05.bp.com\\ea_sap_basis2$", "-Persist"]);
auto p = "R:\\BACKUP";
if (!p.isValidPath && !p.strip.isValidFilename || !p.exists ) { 
writeln("Invalid File Path (", p, ") or Path do not Exist"); }
else { writeln("File Exist :", p); }

}
From,
Vino.B


More information about the Digitalmars-d-learn mailing list