Indigo Rose Software
  #1  
Old 11-04-2008
KevinD KevinD is offline
Forum Member
 
Join Date: Nov 2005
Posts: 50
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, "");
The program that is being installed has four configuration settings which the user can select to install or not. In the On Post Install Actions tab I have a table which the names of the config files. a loop checks for the presence of the config file and makes a few modifications if needed. That part works fine.

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)
The help file describes this as "Could not create the folder for the shortcut.".

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
The installer is being run on Windows Server 2003.

What am I missing?

Thanks in advance.
Kevin
Reply With Quote
  #2  
Old 11-04-2008
searcher123 searcher123 is offline
Forum Member
 
Join Date: Jun 2007
Posts: 59
Quote:
Originally Posted by KevinD View Post
(...)
sArgs = "-L:" .. sFile;
sDescription = sFile;
(...)
First of all, where is sFile defined in your code?
Reply With Quote
  #3  
Old 11-04-2008
jassing's Avatar
jassing jassing is offline
Indigo Rose Customer
 
Join Date: Jan 2001
Location: Anderson Island, WA, USA
Posts: 1,899
Quote:
Originally Posted by KevinD View Post
Code:
Error		Script: On Post Install, Line 37 (2300)
What am I missing?
Telling us what is on line 37...
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.
Reply With Quote
  #4  
Old 11-05-2008
KevinD KevinD is offline
Forum Member
 
Join Date: Nov 2005
Posts: 50
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
cTempFolder is created in On Startup as follows:

Code:
cTempStart = _TempFolder;
nLast = String.ReverseFind(cTempStart, "\\", false);

cTempFolder = String.AbbreviateFilePath(SessionVar.Expand( "%TempFolder%" ), nLast);
As I said the code works except for the Shell.CreateShortCut call (line 37) this is where it fails.

Kevin
Reply With Quote
  #5  
Old 11-05-2008
jassing's Avatar
jassing jassing is offline
Indigo Rose Customer
 
Join Date: Jan 2001
Location: Anderson Island, WA, USA
Posts: 1,899
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.
Reply With Quote
  #6  
Old 11-05-2008
KevinD KevinD is offline
Forum Member
 
Join Date: Nov 2005
Posts: 50
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
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


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.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Copyright © 2000 - 2009 Indigo Rose Corporation. All rights reserved.
Indigo Rose Software