I created a perl script for adding users to Active Directory a few months ago. On Windows 7 it runs fine. On Windows 10 perl is not able to run "dsquery" or "dsadd" but I can really not understand this.
When I run "dsquery" from the same command line, it works. Trying with the perl script… It won't!
Der Befehl "C:\Windows\System32\dsquery.exe" ist entweder falsch geschrieben oder konnte nicht gefunden werden.
(= Command dsquery could not be found…)
Some code snippets from the perl script:
$datetime = strftime("%d.%m.%Y %H:%M:%S", localtime);
&GetOptions ("-v=s" => \$fname,
"-n=s" => \$sname,
"-u=s" => \$uname,
"-p=s" => \$pwd,
"-noshare" =>\$noshare,
"-test" =>\$test,
"-noquota" =>\$noquota,
"-sshpw=s" =>\$sshpw );
unless ($fname) {
print "Vorname: ";
$fname = <STDIN>;
chomp $fname;}
unless ($sname) {
print "Nachname: ";
$sname = <STDIN>;
chomp $sname;}
unless ($uname) {
$uname = substr($fname, 0, 1);
$uname = "$uname.$sname";}
$uname = lc($uname);
if (`C:\\Windows\\System32\\dsquery.exe user -samid $uname`){
print "Benutzer $uname existiert bereits!";
exit;}
At this point it already stops.
But, when I run:
c:\windows\system32\dsquery.exe user -samid ANYUSER
it works.
What is happening right here? Can anyone undestand this??
Cheers,
Lukas
Best Answer
I'm guessing you've a 32 bit install of Perl on a 64 bit OS. There isn't a 32 bit version of
dsquery.exe
inC:\Windows\SysWOW64\
on Windows 10 AMD64. From the 'Run' dialog compare the results of the following.With 32 bit
cmd
:Then explicitly using 64 bit
cmd
:Or just
If you really want to run 64 bit
dsquery.exe
from a 32 bit environment try using thesysnative
alias.Try this in your script, no guarantees that Perl won't just choke on it.