We currently have to import around 200 students into our active directory. We have a BAT file which creates the users and folders on the servers.
I've written a script which scans our MSSQL database for the new students, saves them into an array, and then uses system() to call cmd.exe and run the BAT file to create the students.
The BAT file is located on my Y drive (which is on another server). We currently also use DFS paths so I can access the bat file that way as well.
Its worth noting: 1) Both paths to the BAT file have spaces in them 2) I need to pass arguments to the BAT file as well
At the moment, This is the state of my system() argument in PHP:
$bat = escapeshellcmd("cmd /c Y:\SharedRes\Path To Createstudent\createstudent.bat {$stuArray['forename']} {$stuArray['surname']} {$stuArray['username']} {$stuArray['year']} {$stuArray['sf']}");
system($bat);
And with the DFS Path:
$bat = escapeshellcmd("cmd /c '\\organisation.local\Path To Createstudent\createstudent.bat {$stuArray['forename']} {$stuArray['surname']} {$stuArray['username']} {$stuArray['year']} {$stuArray['sf']}'");
system($bat);
Each time I try to run this, I get the following error:
The filename, directory name, or volume label syntax is incorrect
Any ideas how to get PHP to actually run the BAT file? I'm currently stumped.
Many thanks
Phil
P.S I am running the PHP script via command line:
php.exe -f "C:\import.php"