|
#1
|
|||
|
|||
|
Problem creating shortcuts
Can someone please tell me what is wrong with the following code?
Code:
sFolder = SessionVar.Expand("%AppShortcutFolderName%");
sTarget = SessionVar.Expand("%AppFolder%\\cpsproc.exe");
sArgs = "-L:" .. sFile;
sDescription = sFile;
SetupData.WriteToLogFile( "SCFolder\t" .. sFolder .. "\r\n", true );
SetupData.WriteToLogFile( "SCTarget\t" .. sTarget .. "\r\n", true );
SetupData.WriteToLogFile( "SCArgs\t" .. sArgs .. "\r\n", true );
SetupData.WriteToLogFile( "SCTitle\t" .. sDescription .. "\r\n", true );
Shell.CreateShortcut(sFolder, sDescription, sTarget, sArgs, SessionVar.Expand("%AppFolder%"), sTarget, 0, SW_SHOWNORMAL, nil, "");
Next I want the installer to create individual shortucts to the EXE passing the config file as an arugment and using a different name for each. The script fails at the Shell.CreateShortcut line above. The log file returns Code:
Error Script: On Post Install, Line 37 (2300) I get the same error if the EXE file properties are set to create an icon or not. The SetupData lines return the following which are as expected: Code:
[11/04/2008 17:59:14] SCFolder Kevin Murphy\CPS Processor [11/04/2008 17:59:15] SCTarget E:\Program Files\Kevin Murphy\CPS Processor\cpsproc.exe [11/04/2008 17:59:15] SCArgs -L:cps.ini [11/04/2008 17:59:15] SCDescript cps.ini What am I missing? Thanks in advance. Kevin |
|
#2
|
|||
|
|||
|
First of all, where is sFile defined in your code?
|
|
#3
|
||||
|
||||
|
Quote:
If you use home-brew functions in post-install; line 37 could be from global functions or lua script file... not necessarily in post-install actions. also you're not showing us the right stuff. On the code you show SetupData.WriteToLogFile( "SCTitle\t" .. sDescription .. "\r\n", true ); but the output shows [11/04/2008 17:59:15] SCDescript cps.ini Last edited by jassing; 11-04-2008 at 04:57 PM. |
|
#4
|
|||
|
|||
|
searcher123,
sFile is defined earlier in the code and is the name of the configuration file which is to updated in the loop and for which a shortcut is to be created. jassing, Line 37 is the line where the Shell.CreateShrotCut function is called. I thought I mentioned that in my original post but apparently not. As for the output, the SetupData entries I added to record the values being set and included them to try indicate that the correct values were being set and to show the values being passed to the ShortCut routine but obviously did not include enough explanation. I did not include the full code as I thought it might be a distraction as it works if I leave out the call to Shell.CreateShortCut. It is now shown below. Code:
-- File list
aCfg = {};
aCfg[1] = "cps.ini";
aCfg[2] = "cps_cpsonly.ini";
aCfg[3] = "cps_threshold.ini";
aCfg[4] = "cpssuspicious299.ini";
sCfgDir = SessionVar.Expand("%ApplicationDataFolderCommon%\\%CompanyName%\\%ProductName%\\config\\")
-- Loop through files
for i,k in aCfg do
sFile = k;
result = File.DoesExist(sCfgDir .. sFile);
if result then
SetupData.WriteToLogFile( "CfgFile\t" .. sFile .. "\r\n", true )
-- Create shortcut
sFolder = SessionVar.Expand("%AppShortcutFolderName%");
sTarget = SessionVar.Expand("%AppFolder%\\cpsproc.exe");
sArgs = "-L:" .. sFile;
sDescription = sFile;
SetupData.WriteToLogFile( "SCFolder\t" .. sFolder .. "\r\n", true );
SetupData.WriteToLogFile( "SCTarget\t" .. sTarget .. "\r\n", true );
SetupData.WriteToLogFile( "SCArgs\t" .. sArgs .. "\r\n", true );
SetupData.WriteToLogFile( "SCTitle\t" .. sDescription .. "\r\n", true );
Shell.CreateShortcut(sFolder, sDescription, sTarget, sArgs, SessionVar.Expand("%AppFolder%"), sTarget, 0, SW_SHOWNORMAL, nil, "");
-- Add CfgDir to file
sFile = sCfgDir .. sFile;
-- WorkDir
cWorkDir = INIFile.GetValue( sFile, "CPS", "WorkDir" );
if cWorkDir == "" then
cWorkDir = SessionVar.Expand("%ApplicationDataFolderCommon%\\%CompanyName%\\%ProductName%\\work");
Folder.Create(cWorkDir);
created = Application.GetLastError();
if created > 0 then
cWorkDir = cTempFolder;
else
SetupData.WriteToLogFile( "Created\tWorkDir" .. cWorkDir );
end
INIFile.SetValue(sFile, "CPS", "WorkDir", cWorkDir);
end
-- RemoteScan Section
-- Folder
CurVal = INIFile.GetValue( sFile, "RemoteScan", "RemoteFolder");
if CurVal == "" then
INIFile.SetValue( sFile, "RemoteScan", "RemoteFolder", "#RemoteFolder#" );
end
-- Drive
CurVal = INIFile.GetValue(sFile, "CPS", "MapTo");
if CurVal == "" then
INIFile.SetValue(sFile, "CPS", "MapTo", "#MapTo");
end
-- Username
CurVal = INIFile.GetValue(sFile, "CPS", "UserName");
if CurVal == "" then
INIFile.SetValue(sFile, "CPS", "UserName", "#UserName");
end
-- Password
CurVal = INIFile.GetValue(sFile, "CPS", "Password");
if CurVal == "" then
INIFile.SetValue(sFile, "CPS", "Password", "#Password");
end
end
end
Code:
cTempStart = _TempFolder; nLast = String.ReverseFind(cTempStart, "\\", false); cTempFolder = String.AbbreviateFilePath(SessionVar.Expand( "%TempFolder%" ), nLast); Kevin |
|
#5
|
||||
|
||||
|
you're using string.abbriviatepath incorrectly....
sfolder needs to be a Full path; not just a relative path Last edited by jassing; 11-05-2008 at 11:56 AM. |
|
#6
|
|||
|
|||
|
jassing,
Thanks for that. I assumed that %AppShortcutFolderName% would give the full path or when needed the method would know what to do. I didn't spot this. Thanks again. Kevin |
![]() |
«
Previous Thread
|
Next Thread
»
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Shortcuts problem | cdundee | MSI Factory 2.0 Discussion | 3 | 07-13-2007 10:29 AM |
| Creating Shortcuts in users Favorites | Brunzwick | AutoPlay Media Studio 5.0 | 23 | 11-01-2004 04:40 PM |
| Problem creating Cd | boroarke | AutoPlay Media Studio 5.0 | 2 | 10-04-2004 04:56 PM |
| HOWTO: Create Nested Shortcuts in the Start Menu | Support | Setup Factory 6.0 Knowledge Base | 0 | 09-24-2002 11:26 AM |
| Finding and Creating Shortcuts | JAT | Setup Factory 5.0 | 1 | 08-03-2000 10:48 AM |
All times are GMT -6. The time now is 04:28 AM.









Linear Mode

