Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is RUN command still used?

Status
Not open for further replies.

Neil Toulouse

Programmer
Mar 18, 2002
882
GB
Hi guys

I have been dragged into a project for creating thousands of users on an Active Directory, from data held in a VFP table. Easy (I thought) just use the RUN command to issue NET user commands to populate the AD.

However I can't seem to get the RUN command to work. I am being told that the PIF is not compatible with this 64-bit version of Windows (or something of that ilk) so I got stuck. Then I thought this maybe is a very old hat way of doing things with the command prompt, and so I am here looking for pointers of what today's preferred method is?

BTW, I am on VFP8 64-bit Windows 7 if it makes any odds!

TIA

Neil

I like work. It fascinates me. I can sit and look at it for hours...
 
Thanks Mike - I will look into that, but I am guessing I can't test it without being on an Active Directory server? Definately the way forward for though! Probably still need a quick and dirty method.. ;)

I like work. It fascinates me. I can sit and look at it for hours...
 
Weird - just came across this post:


...and an answer was to rename FOXRUN. So I went searching for it and that seemed to be the problem as it was called FOXRUN not FOXRUN.PIF. SO I changed the name and now i am getting the RUN command working again :)



I like work. It fascinates me. I can sit and look at it for hours...
 
Neil,

I see you've solved your immediate problem. I would add that, although the RUN command works the way it always has, I would always recommend ShellExeucute() as a better option. It is easier and much more flexible.

For more information, see (I wrote that aritcle 11 years ago; I don't recall ever using RUN since then.)

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
Are you sure it wasn't just Windows explorer suppressing file extensions? Maybe now you named your file foxrun.pif.pif and the way it works is VFP doesn't find it any more.

Actually RUN works without any pif file, you just have to configure the Windows environment variable %ComSpec% to point to C:\Windows\system32\cmd.exe - It's the last thing VFP looks for, but it also works.

I use RUN /N to run a VFP exe from another exe and that works, also on Win7, it has worked for about 12 years and still works. I refuse to change that to Shellexecute just for sake of never change a running system.

The RUN topic says you should avoid using run, if you want to pass the Windows 2000 Logo Certification and use ShellExecute Ex instead.

Bye, Olaf.

 
Hi guys

Many thanks for the responses!

Mike - I knew you would have something up you sleeve :)

Olaf - It definately did not have the .PIF extension on it (I always have my windows set to show extensions and hidden files etc) and adding the .PIF allowed it to work.

Anyway I came across this bit of code from somehwere I now can't find to give it its credit:


Code:
LOCAL loWshShell, lcReturnCode
loWshShell = CREATEOBJECT("WScript.Shell")

lcCmd = ;
'NET USER neil pswd /add'

lcReturnCode = loWshShell.RUN(lcCmd, 0, .T.)

This works a treat. lcReturnCode is the 'DOS' %errorlevel% generated by the command.

Short and sweet I thought :)

Neil

I like work. It fascinates me. I can sit and look at it for hours...
 
Neil,

Sorry to put a damper on it, but keep in mind that your code depends on the user not having disabled scripting within Windows. At one time, it was common for IT people to disable scripting on security grounds, which means that code like what you showed won't work. I think that's less common now, but it is worth keeping in mind.

Mike



__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
Well, I'm not sure you're aware, but this RUN has nothing to do with VFP RUN, it compares, but is not depending on any PIF file or extension, it's a method of the Wscrip.Shell and if it doesn't work, most probably Mike is right with his warning, that the Windows Scripting Host might be disabled.

Bye, Olaf.
 
Thanks for the heads up on this I will go and have a chat with the network boys and see what they say :)

I like work. It fascinates me. I can sit and look at it for hours...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top