PDA

View Full Version : Run Program vs Run Command Line



NewsArchive
11-13-2009, 02:08 AM
I am trying to execute rmtshare.exe from within SetupBuilder.
Not getting an error, but it is also not changing the permissions of the
share folder.

Currently I have:
Run Program %_SB_INSTALLDIR%\Tools\rmtshare.exe \\%PC_NAME%\TCS_Client$
/GRANT EVERYONE:r (Always Install) [ShellExecuteEx] [Wait]

I have tried both "with" and "with out" ShellExecute, as well as "run
command line"
None of them seem to work.

Now, if I Run %_SB_INSTALLDIR%\Tools\TCS_rmtshare.bat
(which contains:
rmtshare.exe \\TCS33\TCS_Client$ /GRANT EVERYONE:r
), it works fine.

(TCS33 is my text server name.)

Any thoughts?

Glenn Paschal

NewsArchive
11-13-2009, 02:09 AM
Hi Glenn,

>
> Any thoughts?

I would suggest to check the return values for Run Program:

- If the function succeeds, the %_SB_ERRORCODE% return value is zero.

- If the function fails, the %_SB_ERRORCODE% return value is nonzero. A
return value of 259 means the application is still running.

- The %_SB_ERRORCODE% return value can also hold the last exit code returned
by the executable associated with the work item on its last run.

- The %_SB_RETURNEX% variable holds the error code provided by the
GetLastError Windows API if the CreateProcess function failed. It holds a
system error code if a call to the ShellExecuteEx API failed.

--
Friedrich Linder
Lindersoft
www.lindersoft.com
+1.954.252.3910

SetupBuilder is Windows installation -- "point. click. ship"

-- Official Comodo Code Signing and SSL Certificate Partner

NewsArchive
11-14-2009, 02:39 AM
Checked all that, and no errors are being reported by either _SB_ value.
Only way I have been able to make it work, is to use "Handle Text File" to
create a TCS_Share.BAT file with the rmtshare.exe command in it, then
execute the .BAT

So, what are the real differences between "run command line" and "run
program"?

Glenn Paschal

NewsArchive
11-14-2009, 02:40 AM
Hi Glenn,

> So, what are the real differences between "run command line" and "run
> program"?

"Run Command Line" always uses the CreateProcess() Windows API to execute
programs.

"Run Program" does provide much more functionality. You can use
CreateProcess() or ShellExecuteEx(). And you can run programs non-elevated
from an elevated running application. Of course, it also lets you run a
program elevated from a non-elevated application. All this can't be handled
with "Run Command Line" and the extra options are essential if you have to
support an UAC-aware operating system.

Friedrich

--
Friedrich Linder
Lindersoft
www.lindersoft.com
+1.954.252.3910

SetupBuilder is Windows installation -- "point. click. ship"

-- Official Comodo Code Signing and SSL Certificate Partner

NewsArchive
11-14-2009, 02:44 AM
Glenn,

> Currently I have:
> Run Program %_SB_INSTALLDIR%\Tools\rmtshare.exe \\%PC_NAME%\TCS_Client$
> /GRANT EVERYONE:r (Always Install) [ShellExecuteEx] [Wait]

What do you have as Default Directory?

Friedrich

NewsArchive
11-14-2009, 02:46 AM
Also, put Message Boxes before and after:
Before, so I can check and make sure the file structure is right, and that the exe is in place.
After, so I can check to see if the share permissions had actually changed.

File structure was good, permissions didn't change.

However, for now, this works:
Set Variable %TCS SETPERMISSIONS% to "rmtshare.exe \\%PC NAME%\TCS Client$ /GRANT EVERYONE:r"
Text File: Create File "% SB INSTALLDIR%\Tools\TCS Share.bat"
Text File: Insert Line "0" to "% SB INSTALLDIR%\Tools\TCS Share.bat" -- REM -- Added by Server Patch Process
Text File: Insert Line "0" to "% SB INSTALLDIR%\Tools\TCS Share.bat" -- %TCS SETPERMISSIONS%
Run Program % SB INSTALLDIR%\Tools\TCS Share.bat (Always Install) [ShellExecuteEx] [Wait] [Hide]

Glenn Paschal

NewsArchive
11-14-2009, 02:46 AM
Hi Glenn,

IMO, all your parameters are correct. I don't know why rmtshare.exe does
not work as expected. I debugged it and checked the passed command line;
everything is correct.

Friedrich

NewsArchive
11-14-2009, 02:47 AM
Please note, that it put the immage at the bottom of the last post. The top
part is referencing the image. Sorry. :)

Glenn Paschal

NewsArchive
11-16-2009, 01:37 AM
Hi Glenn,

BTW, are you sure that your syntax is correct?

I might be wrong (because I don't have experiences with rmtshare) but if you
create a hidden share, shouldn't it look like this (line wraps here)

%_SB_INSTALLDIR%\Tools\rmtshare.exe
\\%PC_NAME%\TCS_Client$=%_SB_INSTALLDIR%\Tools /GRANT EVERYONE:r

Friedrich

--
Friedrich Linder
Lindersoft
www.lindersoft.com
+1.954.252.3910

SetupBuilder is Windows installation -- "point. click. ship"

-- Official Comodo Code Signing and SSL Certificate Partner

NewsArchive
11-17-2009, 01:34 AM
no, the share is already created. all i am doing is setting the share
permissions.
The format I am using works from the command line, and from the .BAT file I
create, so I don't believe it is format.

Glenn Paschal

NewsArchive
11-17-2009, 01:35 AM
> no, the share is already created. all i am doing is setting the share
> permissions.
> The format I am using works from the command line, and from the .BAT file
> I create, so I don't believe it is format.

Then I fear, I don't know. There is a difference between calling something
from a batch file and from a Windows API (e.g. ShellExecuteEx or
CreateProcess). So perhaps this causes this. But your problem is not
caused by a SetupBuilder bug, so I fear I can't help :-( All parameters you
provide are correctly passed to rmtshare.exe.

Friedrich

NewsArchive
11-17-2009, 01:36 AM
BTW, this is what is passed to rmtshare.exe (see attached screenshot). It's
exactly what you defined.

Friedrich

NewsArchive
11-17-2009, 01:36 AM
I agree. don't know what is causing it.
Thanks for all your help.

Glenn Paschal

NewsArchive
11-17-2009, 01:37 AM
> I agree. don't know what is causing it.
> Thanks for all your help.

I hate it when there is no logical explanation for a problem.

Friedrich