Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8468637
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T15:59:25+00:00 2026-06-10T15:59:25+00:00

We currently have to import around 200 students into our active directory. We have

  • 0

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"
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T15:59:26+00:00Added an answer on June 10, 2026 at 3:59 pm

    if the batch file is in a path with spaces you need to quote the argument:

    cmd /c "Y:\SharedRes\Path To Createstudent\createstudent.cmd" ...
    

    Also if the parameters contain spaces you need to quote them too. Single quotes are not recognised by cmd, it has to be double quotes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

currently I have the following which parses a json api.. import simplejson import urllib2
So I have this need to import (currently) about 15k products. Each product has
I have a python file that will not correctly perform an import. If I
I currently have a table of concentrations, which are linked to a table of
I currently have a Windows Service which continually runs throughout the day. It has
I have a .sql file with 24k INSERT statements as: INSERT INTO dump(id, title,
I have around 80 lines of a function in a file. I need the
I have recently set up a web server, which currently hosts a couple of
I have written an importer which copies data from a flat table into several
I currently have a large number of CSVs to import to a MySQL database.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.