Page 1 of 1
run a batch file from fwh
Posted: Fri Oct 15, 2021 9:13 am
by Silvio.Falconi
I need to start a batch file that has only one command line from an exe fwh
in the command line enclosed in the bat file it wants three parameters %1 %2 %3
instead of these three parameters the information contained within a dbf must be linked
example
First, Last, Address
any help pls
Re: run a batch file from fwh
Posted: Fri Oct 15, 2021 2:12 pm
by Marc Venken
I would generate/update the bat file itself with the dbf data, just before running it from FWH.
Re: run a batch file from fwh
Posted: Sat Oct 16, 2021 7:06 am
by Silvio.Falconi
perhaps I resolved
I created a txtfile from fwh
and then save as "xxx.bat"
then I make run this bat
But there is a problem because the command I insert on it need level administrator because there is a command NET USER
Re: run a batch file from fwh
Posted: Sat Oct 16, 2021 11:23 am
by Silvio.Falconi
sample :
Code: Select all | Expand
#include "fivewin.ch"
Function test()
local cText := ""
local cUser:="Pon2021"
local cPassword:="Pon"
cText += " NET USER " +cUser +" "+;
cPassword +" /add " +;
" /comment='Pon 2021'" +;
" /expires:never " +;
" /passwordchg:No" +;
" /logonpasswordchg:No"
memowrit("test.bat", cText )
waitrun( "test.bat", 0 )
return nil
this created the file .bat
then it is no executed why ?if you run cmd from administrator and then write
NET USER fwh fwh /add
it execute and create a user called fwh with password fwh
Re: run a batch file from fwh
Posted: Sat Oct 16, 2021 11:44 am
by Otto
Hello Silvio,
Do you run your EXE as admin?
I use the same code as you with no problems.
Best regards,
Otto
Code: Select all | Expand
if lIsDir( cVerzeichnis ) = .f.
lMKDir( cVerzeichnis )
cText := 'net user ' + cUser + ' ' + cPW + ' /add /comment:"Basic WINHOTEL Remotedesktop user account." /fullname:"' + cfullname +'" /logonpasswordchg:no' + CRLF
cText := cText + 'net localgroup "Remotedesktopbenutzer" '+ cUser +' /add' + CRLF
cText := cText + 'net localgroup "Benutzer" ' + cUser + ' /delete' + CRLF
cText := cText + 'WMIC USERACCOUNT WHERE "Name=' + "'" + cUser + "'" + '" SET PasswordExpires=FALSE' + CRLF
memowrit( ".\psfiles\ps_8.bat", cText )
waitrun( ".\psfiles\ps_8.bat" )
endif
Re: run a batch file from fwh
Posted: Mon Oct 18, 2021 8:02 am
by Silvio.Falconi
Otto wrote:Hello Silvio,
Do you run your EXE as admin?
I use the same code as you with no problems.
Best regards,
Otto
Code: Select all | Expand
if lIsDir( cVerzeichnis ) = .f.
lMKDir( cVerzeichnis )
cText := 'net user ' + cUser + ' ' + cPW + ' /add /comment:"Basic WINHOTEL Remotedesktop user account." /fullname:"' + cfullname +'" /logonpasswordchg:no' + CRLF
cText := cText + 'net localgroup "Remotedesktopbenutzer" '+ cUser +' /add' + CRLF
cText := cText + 'net localgroup "Benutzer" ' + cUser + ' /delete' + CRLF
cText := cText + 'WMIC USERACCOUNT WHERE "Name=' + "'" + cUser + "'" + '" SET PasswordExpires=FALSE' + CRLF
memowrit( ".\psfiles\ps_8.bat", cText )
waitrun( ".\psfiles\ps_8.bat" )
endif
thanks Otto
I thought that I could directly load test.bat an exe program and load it in administrator mode,
now I have to remember to load the exe in administrator mode
a question
what do you do with the command
Re: run a batch file from fwh
Posted: Mon Oct 18, 2021 8:10 am
by Otto
Silvio, WINDOWS is a very save OS.
Best regards,
Otto
Re: run a batch file from fwh
Posted: Mon Oct 18, 2021 9:33 am
by driessen
Silvio,
Why don't you make a LNK-file (like shortcut) in which you can define to run it as an administrator.
In your application you use the
WaitRun("XXXX.LNK,0)
Doesn't that work?
Re: run a batch file from fwh
Posted: Mon Oct 18, 2021 9:45 am
by Silvio.Falconi
driessen wrote:Silvio,
Why don't you make a LNK-file (like shortcut) in which you can define to run it as an administrator.
In your application you use the
WaitRun("XXXX.LNK,0)
Doesn't that work?
I have at my school 3 labs with 22 computer each I wish to find a faster way to create user accounts for students