Here is a macro I wrote. I wrote it using v12.1.10. It's a simple macro. All it does is change the default location where programs are installed. The default being C:\Program Files. You can choose another location as your default.
Only tested for Windows XP. Be carefull if your not using XP. I don't know if the settings are the same in other Windows.
See continued post after this script>>>>
Code: Select all
Let>VAREXPLICIT=1
let>RootKey=HKEY_LOCAL_MACHINE
let>Key=\SOFTWARE\Microsoft\Windows\CurrentVersion
LabelToVar>OutputScript,ProgramScript
Dialog>Dialog1
object Dialog1: TForm
Left = 251
Top = 104
HelpContext = 5000
BorderIcons = [biSystemMenu]
Caption = 'Default Program Path'
ClientHeight = 66
ClientWidth = 466
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
Menu = MainMenu
OldCreateOrder = True
Position = poDesktopCenter
ShowHint = True
OnTaskBar = False
PixelsPerInch = 96
TextHeight = 13
object Edit1: TEdit
Left = 16
Top = 24
Width = 280
Height = 21
TabOrder = 0
end
object MSButton1: tMSButton
Left = 304
Top = 20
Width = 33
Height = 25
DoubleBuffered = True
Glyph.Data = {
F6000000424DF600000000000000760000002800000010000000100000000100
0400000000008000000000000000000000001000000010000000000000000000
80000080000000808000800000008000800080800000C0C0C000808080000000
FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF00777777777777
77777777777777777777000000000007777700333333333077770B0333333333
07770FB03333333330770BFB0333333333070FBFB000000000000BFBFBFBFB07
77770FBFBFBFBF0777770BFB0000000777777000777777770007777777777777
7007777777770777070777777777700077777777777777777777}
ParentDoubleBuffered = False
TabOrder = 1
DoBrowse = False
BrowseStyle = fbOpen
end
object MSButton2: tMSButton
Left = 345
Top = 20
Width = 50
Height = 25
Caption = 'Cancel'
DoubleBuffered = True
ParentDoubleBuffered = False
TabOrder = 2
DoBrowse = False
BrowseStyle = fbOpen
end
object MSButton3: tMSButton
Left = 399
Top = 20
Width = 50
Height = 25
Caption = 'Apply'
DoubleBuffered = True
ParentDoubleBuffered = False
TabOrder = 3
DoBrowse = False
BrowseStyle = fbOpen
end
object MainMenu: tMSMainMenu
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
object MenuItem1: tMSMenuItem
Caption = 'Script'
object MenuItem2: tMSMenuItem
Caption = 'View'
end
object MenuItem3: tMSMenuItem
Caption = 'Print'
end
end
end
end
EndDialog>Dialog1
Dialog>Dialog5
object Dialog5: TForm
Left = 426
Top = 146
HelpContext = 5000
BorderIcons = [biSystemMenu]
Caption = 'View Script'
ClientHeight = 216
ClientWidth = 439
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = True
Position = poScreenCenter
ShowHint = True
OnTaskBar = False
PixelsPerInch = 96
TextHeight = 13
object MSMemo1: tMSMemo
Left = 0
Top = 0
Width = 439
Height = 216
Align = alClient
ScrollBars = ssBoth
TabOrder = 0
end
end
EndDialog>Dialog5
AddDialogHandler>Dialog1,MSButton1,OnClick,DoBrowse
AddDialogHandler>Dialog1,MSButton2,OnClick,DoExit
AddDialogHandler>Dialog1,MSButton3,OnClick,DoApply
AddDialogHandler>Dialog1,MenuItem2,OnClick,DoView
AddDialogHandler>Dialog1,MenuItem3,OnClick,DoLocation
RegistryReadKey>%RootKey%,%Key%,ProgramFilesDir,ProgramFilesDir
SetDialogProperty>Dialog1,Edit1,Text,%ProgramFilesDir%
Show>Dialog1,r
srt>DoApply
LibFunc>user32,MessageBoxA,res,0,Changing to : %ProgramFilesDir%%crlf%Are you sure?,Change Default Program Location,35
if>%res%=6
RegistryWriteKey>%RootKey%,%Key%,ProgramFilesDir,%ProgramFilesDir%
endif
if>%res%=2
GoSub>DoExit
endif
END>DoApply
SRT>DoBrowse
SetDialogProperty>Dialog1,MSButton1,InitialDir,%ProgramFilesDir%
SetDialogProperty>Dialog1,MSButton1,BrowseStyle,fbFolder
SetDialogProperty>Dialog1,MSButton1,DoBrowse,True
SetDialogProperty>Dialog1,MSButton1,InitialDir,%ProgramFilesDir%
GetDialogProperty>Dialog1,MSButton1,Filename,ProgramFilesDir
SetDialogProperty>Dialog1,Edit1,Text,%ProgramFilesDir%
END>DoBrowse
SRT>DoLocation
LibFunc>user32,MessageBoxA,r,0,Please choose destination folder for script.,Print Script,64
SetDialogProperty>Dialog1,MSButton1,InitialDir,%Desktop_Dir%
SetDialogProperty>Dialog1,MSButton1,BrowseStyle,fbFolder
SetDialogProperty>Dialog1,MSButton1,DoBrowse,True
GetDialogProperty>Dialog1,MSButton1,Filename,ScriptLocation
WriteLn>%ScriptLocation%\Program_Script.txt,wtf,%ProgramScript%
if>%wtf%=0
LibFunc>user32,MessageBoxA,r,0, Script has been sucessfully written to -%crlf%%ScriptLocation% %crlf% Filename = Program_Script.txt,Success,64
else
LibFunc>user32,MessageBoxA,r,0,Unable to write script. Try again.(%wtf%),Write Failed!,16
endif
END>DoLocation
srt>DoView
SetDialogProperty>Dialog5,MSMemo1,Text,%ProgramScript%
Show>Dialog5,b
END>DoView
srt>DoExit
exit
END>DoExit
/*
OutputScript:
Let>VAREXPLICIT=1
let>RootKey=HKEY_LOCAL_MACHINE
let>Key=\SOFTWARE\Microsoft\Windows\CurrentVersion
LabelToVar>OutputScript,ProgramScript
Dialog>Dialog1
object Dialog1: TForm
Left = 251
Top = 104
HelpContext = 5000
BorderIcons = [biSystemMenu]
Caption = 'Default Program Path'
ClientHeight = 66
ClientWidth = 466
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
Menu = MainMenu
OldCreateOrder = True
Position = poDesktopCenter
ShowHint = True
OnTaskBar = False
PixelsPerInch = 96
TextHeight = 13
object Edit1: TEdit
Left = 16
Top = 24
Width = 280
Height = 21
TabOrder = 0
end
object MSButton1: tMSButton
Left = 304
Top = 20
Width = 33
Height = 25
DoubleBuffered = True
Glyph.Data = {
F6000000424DF600000000000000760000002800000010000000100000000100
0400000000008000000000000000000000001000000010000000000000000000
80000080000000808000800000008000800080800000C0C0C000808080000000
FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF00777777777777
77777777777777777777000000000007777700333333333077770B0333333333
07770FB03333333330770BFB0333333333070FBFB000000000000BFBFBFBFB07
77770FBFBFBFBF0777770BFB0000000777777000777777770007777777777777
7007777777770777070777777777700077777777777777777777}
ParentDoubleBuffered = False
TabOrder = 1
DoBrowse = False
BrowseStyle = fbOpen
end
object MSButton2: tMSButton
Left = 345
Top = 20
Width = 50
Height = 25
Caption = 'Cancel'
DoubleBuffered = True
ParentDoubleBuffered = False
TabOrder = 2
DoBrowse = False
BrowseStyle = fbOpen
end
object MSButton3: tMSButton
Left = 399
Top = 20
Width = 50
Height = 25
Caption = 'Apply'
DoubleBuffered = True
ParentDoubleBuffered = False
TabOrder = 3
DoBrowse = False
BrowseStyle = fbOpen
end
object MainMenu: tMSMainMenu
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
object MenuItem1: tMSMenuItem
Caption = 'Script'
object MenuItem2: tMSMenuItem
Caption = 'View'
end
object MenuItem3: tMSMenuItem
Caption = 'Print'
end
end
end
end
EndDialog>Dialog1
Dialog>Dialog5
object Dialog5: TForm
Left = 426
Top = 146
HelpContext = 5000
BorderIcons = [biSystemMenu]
Caption = 'View Script'
ClientHeight = 216
ClientWidth = 439
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = True
Position = poScreenCenter
ShowHint = True
OnTaskBar = False
PixelsPerInch = 96
TextHeight = 13
object MSMemo1: tMSMemo
Left = 0
Top = 0
Width = 439
Height = 216
Align = alClient
ScrollBars = ssBoth
TabOrder = 0
end
end
EndDialog>Dialog5
AddDialogHandler>Dialog1,MSButton1,OnClick,DoBrowse
AddDialogHandler>Dialog1,MSButton2,OnClick,DoExit
AddDialogHandler>Dialog1,MSButton3,OnClick,DoApply
AddDialogHandler>Dialog1,MenuItem2,OnClick,DoView
AddDialogHandler>Dialog1,MenuItem3,OnClick,DoLocation
RegistryReadKey>%RootKey%,%Key%,ProgramFilesDir,ProgramFilesDir
SetDialogProperty>Dialog1,Edit1,Text,%ProgramFilesDir%
Show>Dialog1,r
srt>DoApply
LibFunc>user32,MessageBoxA,res,0,Changing to : %ProgramFilesDir%%crlf%Are you sure?,Change Default Program Location,35
if>%res%=6
RegistryWriteKey>%RootKey%,%Key%,ProgramFilesDir,%ProgramFilesDir%
endif
if>%res%=2
GoSub>DoExit
endif
END>DoApply
SRT>DoBrowse
SetDialogProperty>Dialog1,MSButton1,InitialDir,%ProgramFilesDir%
SetDialogProperty>Dialog1,MSButton1,BrowseStyle,fbFolder
SetDialogProperty>Dialog1,MSButton1,DoBrowse,True
SetDialogProperty>Dialog1,MSButton1,InitialDir,%ProgramFilesDir%
GetDialogProperty>Dialog1,MSButton1,Filename,ProgramFilesDir
SetDialogProperty>Dialog1,Edit1,Text,%ProgramFilesDir%
END>DoBrowse
*/
/*
SRT>DoLocation
LibFunc>user32,MessageBoxA,r,0,Please choose destination folder for script.,Print Script,64
SetDialogProperty>Dialog1,MSButton1,InitialDir,%Desktop_Dir%
SetDialogProperty>Dialog1,MSButton1,BrowseStyle,fbFolder
SetDialogProperty>Dialog1,MSButton1,DoBrowse,True
GetDialogProperty>Dialog1,MSButton1,Filename,ScriptLocation
WriteLn>%ScriptLocation%\Program_Script.txt,wtf,%ProgramScript%
if>%wtf%=0
LibFunc>user32,MessageBoxA,r,0, Script has been sucessfully written to -%crlf%%ScriptLocation% %crlf% Filename = Program_Script.txt,Success,64
else
LibFunc>user32,MessageBoxA,r,0,Unable to write script. Try again.(%wtf%),Write Failed!,16
endif
END>DoLocation
srt>DoView
SetDialogProperty>Dialog5,MSMemo1,Text,%ProgramScript%
Show>Dialog5,b
END>DoView
srt>DoExit
exit
END>DoExit
*/
Try adding Block 2 (the last comment block) to the bottom of block 1. Then run the script. Did you get an error?
I keep getting an error that says "Line 5 variable refers to itself......"
Between the two blocks just remove the */ and /* to make it one comment block. I even cut and pasted it, and still got an error.
Please post your results,
PepsiHog